| 1 | |
| 2 | * Copyright (c) 2016 Intel Corporation
|
| 3 | *
|
| 4 | * Permission to use, copy, modify, distribute, and sell this software and its
|
| 5 | * documentation for any purpose is hereby granted without fee, provided that
|
| 6 | * the above copyright notice appear in all copies and that both that copyright
|
| 7 | * notice and this permission notice appear in supporting documentation, and
|
| 8 | * that the name of the copyright holders not be used in advertising or
|
| 9 | * publicity pertaining to distribution of the software without specific,
|
| 10 | * written prior permission. The copyright holders make no representations
|
| 11 | * about the suitability of this software for any purpose. It is provided "as
|
| 12 | * is" without express or implied warranty.
|
| 13 | *
|
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
| 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
| 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
| 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
| 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
| 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
| 20 | * OF THIS SOFTWARE.
|
| 21 |
|
| 22 |
|
| 23 | #include <drm/drm_auth.h>
|
| 24 | #include <drm/drm_connector.h>
|
| 25 | #include <drm/drm_drv.h>
|
| 26 | #include <drm/drm_edid.h>
|
| 27 | #include <drm/drm_encoder.h>
|
| 28 | #include <drm/drm_file.h>
|
| 29 | #include <drm/drm_managed.h>
|
| 30 | #include <drm/drm_panel.h>
|
| 31 | #include <drm/drm_print.h>
|
| 32 | #include <drm/drm_privacy_screen_consumer.h>
|
| 33 | #include <drm/drm_sysfs.h>
|
| 34 | #include <drm/drm_utils.h>
|
| 35 |
|
| 36 | #include <linux/export.h>
|
| 37 | #include <linux/platform_device.h>
|
| 38 | #include <linux/property.h>
|
| 39 | #include <linux/uaccess.h>
|
| 40 |
|
| 41 | #include <video/cmdline.h>
|
| 42 |
|
| 43 | #include "drm_crtc_internal.h"
|
| 44 | #include "drm_internal.h"
|
| 45 |
|
| 46 | |
| 47 | * DOC: overview
|
| 48 | *
|
| 49 | * In DRM connectors are the general abstraction for display sinks, and include
|
| 50 | * also fixed panels or anything else that can display pixels in some form. As
|
| 51 | * opposed to all other KMS objects representing hardware (like CRTC, encoder or
|
| 52 | * plane abstractions) connectors can be hotplugged and unplugged at runtime.
|
| 53 | * Hence they are reference-counted using drm_connector_get() and
|
| 54 | * drm_connector_put().
|
| 55 | *
|
| 56 | * KMS driver must create, initialize, register and attach at a &struct
|
| 57 | * drm_connector for each such sink. The instance is created as other KMS
|
| 58 | * objects and initialized by setting the following fields. The connector is
|
| 59 | * initialized with a call to drm_connector_init() with a pointer to the
|
| 60 | * &struct drm_connector_funcs and a connector type, and then exposed to
|
| 61 | * userspace with a call to drm_connector_register().
|
| 62 | *
|
| 63 | * Connectors must be attached to an encoder to be used. For devices that map
|
| 64 | * connectors to encoders 1:1, the connector should be attached at
|
| 65 | * initialization time with a call to drm_connector_attach_encoder(). The
|
| 66 | * driver must also set the &drm_connector.encoder field to point to the
|
| 67 | * attached encoder.
|
| 68 | *
|
| 69 | * For connectors which are not fixed (like built-in panels) the driver needs to
|
| 70 | * support hotplug notifications. The simplest way to do that is by using the
|
| 71 | * probe helpers, see drm_kms_helper_poll_init() for connectors which don't have
|
| 72 | * hardware support for hotplug interrupts. Connectors with hardware hotplug
|
| 73 | * support can instead use e.g. drm_helper_hpd_irq_event().
|
| 74 |
|
| 75 |
|
| 76 | |
| 77 | * Global connector list for drm_connector_find_by_fwnode().
|
| 78 | * Note drm_connector_[un]register() first take connector->lock and then
|
| 79 | * take the connector_list_lock.
|
| 80 |
|
| 81 | static DEFINE_MUTEX(connector_list_lock);
|
| 82 | static LIST_HEAD(connector_list);
|
| 83 |
|
| 84 | struct drm_conn_prop_enum_list {
|
| 85 | int type;
|
| 86 | const char *name;
|
| 87 | struct ida ida;
|
| 88 | };
|
| 89 |
|
| 90 | |
| 91 | * Connector and encoder types.
|
| 92 |
|
| 93 | static struct drm_conn_prop_enum_list drm_connector_enum_list[] = {
|
| 94 | { DRM_MODE_CONNECTOR_Unknown, "Unknown" },
|
| 95 | { DRM_MODE_CONNECTOR_VGA, "VGA" },
|
| 96 | { DRM_MODE_CONNECTOR_DVII, "DVI-I" },
|
| 97 | { DRM_MODE_CONNECTOR_DVID, "DVI-D" },
|
| 98 | { DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
|
| 99 | { DRM_MODE_CONNECTOR_Composite, "Composite" },
|
| 100 | { DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO" },
|
| 101 | { DRM_MODE_CONNECTOR_LVDS, "LVDS" },
|
| 102 | { DRM_MODE_CONNECTOR_Component, "Component" },
|
| 103 | { DRM_MODE_CONNECTOR_9PinDIN, "DIN" },
|
| 104 | { DRM_MODE_CONNECTOR_DisplayPort, "DP" },
|
| 105 | { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
|
| 106 | { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
|
| 107 | { DRM_MODE_CONNECTOR_TV, "TV" },
|
| 108 | { DRM_MODE_CONNECTOR_eDP, "eDP" },
|
| 109 | { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
|
| 110 | { DRM_MODE_CONNECTOR_DSI, "DSI" },
|
| 111 | { DRM_MODE_CONNECTOR_DPI, "DPI" },
|
| 112 | { DRM_MODE_CONNECTOR_WRITEBACK, "Writeback" },
|
| 113 | { DRM_MODE_CONNECTOR_SPI, "SPI" },
|
| 114 | { DRM_MODE_CONNECTOR_USB, "USB" },
|
| 115 | };
|
| 116 |
|
| 117 | void drm_connector_ida_init(void)
|
| 118 | {
|
| 119 | int i;
|
| 120 |
|
| 121 | for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++)
|
| 122 | ida_init(&drm_connector_enum_list[i].ida);
|
| 123 | }
|
| 124 |
|
| 125 | void drm_connector_ida_destroy(void)
|
| 126 | {
|
| 127 | int i;
|
| 128 |
|
| 129 | for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++)
|
| 130 | ida_destroy(&drm_connector_enum_list[i].ida);
|
| 131 | }
|
| 132 |
|
| 133 | |
| 134 | * drm_get_connector_type_name - return a string for connector type
|
| 135 | * @type: The connector type (DRM_MODE_CONNECTOR_*)
|
| 136 | *
|
| 137 | * Returns: the name of the connector type, or NULL if the type is not valid.
|
| 138 |
|
| 139 | const char *drm_get_connector_type_name(unsigned int type)
|
| 140 | {
|
| 141 | if (type < ARRAY_SIZE(drm_connector_enum_list))
|
| 142 | return drm_connector_enum_list[type].name;
|
| 143 |
|
| 144 | return NULL;
|
| 145 | }
|
| 146 | EXPORT_SYMBOL(drm_get_connector_type_name);
|
| 147 |
|
| 148 | |
| 149 | * drm_connector_get_cmdline_mode - reads the user's cmdline mode
|
| 150 | * @connector: connector to query
|
| 151 | *
|
| 152 | * The kernel supports per-connector configuration of its consoles through
|
| 153 | * use of the video= parameter. This function parses that option and
|
| 154 | * extracts the user's specified mode (or enable/disable status) for a
|
| 155 | * particular connector. This is typically only used during the early fbdev
|
| 156 | * setup.
|
| 157 |
|
| 158 | static void drm_connector_get_cmdline_mode(struct drm_connector *connector)
|
| 159 | {
|
| 160 | struct drm_cmdline_mode *mode = &connector->cmdline_mode;
|
| 161 | const char *option;
|
| 162 |
|
| 163 | option = video_get_options(connector->name);
|
| 164 | if (!option)
|
| 165 | return;
|
| 166 |
|
| 167 | if (!drm_mode_parse_command_line_for_connector(option,
|
| 168 | connector,
|
| 169 | mode))
|
| 170 | return;
|
| 171 |
|
| 172 | if (mode->force) {
|
| 173 | DRM_INFO("forcing %s connector %s\n", connector->name,
|
| 174 | drm_get_connector_force_name(mode->force));
|
| 175 | connector->force = mode->force;
|
| 176 | }
|
| 177 |
|
| 178 | if (mode->panel_orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN) {
|
| 179 | DRM_INFO("cmdline forces connector %s panel_orientation to %d\n",
|
| 180 | connector->name, mode->panel_orientation);
|
| 181 | drm_connector_set_panel_orientation(connector,
|
| 182 | mode->panel_orientation);
|
| 183 | }
|
| 184 |
|
| 185 | DRM_DEBUG_KMS("cmdline mode for connector %s %s %dx%d@%dHz%s%s%s\n",
|
| 186 | connector->name, mode->name,
|
| 187 | mode->xres, mode->yres,
|
| 188 | mode->refresh_specified ? mode->refresh : 60,
|
| 189 | mode->rb ? " reduced blanking" : "",
|
| 190 | mode->margins ? " with margins" : "",
|
| 191 | mode->interlace ? " interlaced" : "");
|
| 192 | }
|
| 193 |
|
| 194 | static void drm_connector_free(struct kref *kref)
|
| 195 | {
|
| 196 | struct drm_connector *connector =
|
| 197 | container_of(kref, struct drm_connector, base.refcount);
|
| 198 | struct drm_device *dev = connector->dev;
|
| 199 |
|
| 200 | drm_mode_object_unregister(dev, &connector->base);
|
| 201 | connector->funcs->destroy(connector);
|
| 202 | }
|
| 203 |
|
| 204 | void drm_connector_free_work_fn(struct work_struct *work)
|
| 205 | {
|
| 206 | struct drm_connector *connector, *n;
|
| 207 | struct drm_device *dev =
|
| 208 | container_of(work, struct drm_device, mode_config.connector_free_work);
|
| 209 | struct drm_mode_config *config = &dev->mode_config;
|
| 210 | unsigned long flags;
|
| 211 | struct llist_node *freed;
|
| 212 |
|
| 213 | spin_lock_irqsave(&config->connector_list_lock, flags);
|
| 214 | freed = llist_del_all(&config->connector_free_list);
|
| 215 | spin_unlock_irqrestore(&config->connector_list_lock, flags);
|
| 216 |
|
| 217 | llist_for_each_entry_safe(connector, n, freed, free_node) {
|
| 218 | drm_mode_object_unregister(dev, &connector->base);
|
| 219 | connector->funcs->destroy(connector);
|
| 220 | }
|
| 221 | }
|
| 222 |
|
| 223 | static int drm_connector_init_only(struct drm_device *dev,
|
| 224 | struct drm_connector *connector,
|
| 225 | const struct drm_connector_funcs *funcs,
|
| 226 | int connector_type,
|
| 227 | struct i2c_adapter *ddc)
|
| 228 | {
|
| 229 | struct drm_mode_config *config = &dev->mode_config;
|
| 230 | int ret;
|
| 231 | struct ida *connector_ida =
|
| 232 | &drm_connector_enum_list[connector_type].ida;
|
| 233 |
|
| 234 | WARN_ON(drm_drv_uses_atomic_modeset(dev) &&
|
| 235 | (!funcs->atomic_destroy_state ||
|
| 236 | !funcs->atomic_duplicate_state));
|
| 237 |
|
| 238 | ret = __drm_mode_object_add(dev, &connector->base,
|
| 239 | DRM_MODE_OBJECT_CONNECTOR,
|
| 240 | false, drm_connector_free);
|
| 241 | if (ret)
|
| 242 | return ret;
|
| 243 |
|
| 244 | connector->base.properties = &connector->properties;
|
| 245 | connector->dev = dev;
|
| 246 | connector->funcs = funcs;
|
| 247 |
|
| 248 |
|
| 249 | ret = ida_alloc_max(&config->connector_ida, 31, GFP_KERNEL);
|
| 250 | if (ret < 0) {
|
| 251 | DRM_DEBUG_KMS("Failed to allocate %s connector index: %d\n",
|
| 252 | drm_connector_enum_list[connector_type].name,
|
| 253 | ret);
|
| 254 | goto out_put;
|
| 255 | }
|
| 256 | connector->index = ret;
|
| 257 | ret = 0;
|
| 258 |
|
| 259 | connector->connector_type = connector_type;
|
| 260 | connector->connector_type_id =
|
| 261 | ida_alloc_min(connector_ida, 1, GFP_KERNEL);
|
| 262 | if (connector->connector_type_id < 0) {
|
| 263 | ret = connector->connector_type_id;
|
| 264 | goto out_put_id;
|
| 265 | }
|
| 266 | connector->name =
|
| 267 | kasprintf(GFP_KERNEL, "%s-%d",
|
| 268 | drm_connector_enum_list[connector_type].name,
|
| 269 | connector->connector_type_id);
|
| 270 | if (!connector->name) {
|
| 271 | ret = -ENOMEM;
|
| 272 | goto out_put_type_id;
|
| 273 | }
|
| 274 |
|
| 275 |
|
| 276 | connector->ddc = ddc;
|
| 277 |
|
| 278 | INIT_LIST_HEAD(&connector->head);
|
| 279 | INIT_LIST_HEAD(&connector->global_connector_list_entry);
|
| 280 | INIT_LIST_HEAD(&connector->probed_modes);
|
| 281 | INIT_LIST_HEAD(&connector->modes);
|
| 282 | mutex_init(&connector->mutex);
|
| 283 | mutex_init(&connector->cec.mutex);
|
| 284 | mutex_init(&connector->eld_mutex);
|
| 285 | mutex_init(&connector->edid_override_mutex);
|
| 286 | mutex_init(&connector->hdmi.infoframes.lock);
|
| 287 | mutex_init(&connector->hdmi_audio.lock);
|
| 288 | connector->edid_blob_ptr = NULL;
|
| 289 | connector->epoch_counter = 0;
|
| 290 | connector->tile_blob_ptr = NULL;
|
| 291 | connector->status = connector_status_unknown;
|
| 292 | connector->display_info.panel_orientation =
|
| 293 | DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
|
| 294 |
|
| 295 | drm_connector_get_cmdline_mode(connector);
|
| 296 |
|
| 297 | if (connector_type != DRM_MODE_CONNECTOR_VIRTUAL &&
|
| 298 | connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
|
| 299 | drm_connector_attach_edid_property(connector);
|
| 300 |
|
| 301 | drm_object_attach_property(&connector->base,
|
| 302 | config->dpms_property, 0);
|
| 303 |
|
| 304 | drm_object_attach_property(&connector->base,
|
| 305 | config->link_status_property,
|
| 306 | 0);
|
| 307 |
|
| 308 | drm_object_attach_property(&connector->base,
|
| 309 | config->non_desktop_property,
|
| 310 | 0);
|
| 311 | drm_object_attach_property(&connector->base,
|
| 312 | config->tile_property,
|
| 313 | 0);
|
| 314 |
|
| 315 | if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
|
| 316 | drm_object_attach_property(&connector->base, config->prop_crtc_id, 0);
|
| 317 | }
|
| 318 |
|
| 319 | connector->debugfs_entry = NULL;
|
| 320 | out_put_type_id:
|
| 321 | if (ret)
|
| 322 | ida_free(connector_ida, connector->connector_type_id);
|
| 323 | out_put_id:
|
| 324 | if (ret)
|
| 325 | ida_free(&config->connector_ida, connector->index);
|
| 326 | out_put:
|
| 327 | if (ret)
|
| 328 | drm_mode_object_unregister(dev, &connector->base);
|
| 329 |
|
| 330 | return ret;
|
| 331 | }
|
| 332 |
|
| 333 | static void drm_connector_add(struct drm_connector *connector)
|
| 334 | {
|
| 335 | struct drm_device *dev = connector->dev;
|
| 336 | struct drm_mode_config *config = &dev->mode_config;
|
| 337 |
|
| 338 | if (drm_WARN_ON(dev, !list_empty(&connector->head)))
|
| 339 | return;
|
| 340 |
|
| 341 | spin_lock_irq(&config->connector_list_lock);
|
| 342 | list_add_tail(&connector->head, &config->connector_list);
|
| 343 | config->num_connector++;
|
| 344 | spin_unlock_irq(&config->connector_list_lock);
|
| 345 | }
|
| 346 |
|
| 347 | static void drm_connector_remove(struct drm_connector *connector)
|
| 348 | {
|
| 349 | struct drm_device *dev = connector->dev;
|
| 350 |
|
| 351 | |
| 352 | * For dynamic connectors drm_connector_cleanup() can call this function
|
| 353 | * before the connector is registered and added to the list.
|
| 354 |
|
| 355 | if (list_empty(&connector->head))
|
| 356 | return;
|
| 357 |
|
| 358 | spin_lock_irq(&dev->mode_config.connector_list_lock);
|
| 359 | list_del_init(&connector->head);
|
| 360 | dev->mode_config.num_connector--;
|
| 361 | spin_unlock_irq(&dev->mode_config.connector_list_lock);
|
| 362 | }
|
| 363 |
|
| 364 | static int drm_connector_init_and_add(struct drm_device *dev,
|
| 365 | struct drm_connector *connector,
|
| 366 | const struct drm_connector_funcs *funcs,
|
| 367 | int connector_type,
|
| 368 | struct i2c_adapter *ddc)
|
| 369 | {
|
| 370 | int ret;
|
| 371 |
|
| 372 | ret = drm_connector_init_only(dev, connector, funcs, connector_type, ddc);
|
| 373 | if (ret)
|
| 374 | return ret;
|
| 375 |
|
| 376 | drm_connector_add(connector);
|
| 377 |
|
| 378 | return 0;
|
| 379 | }
|
| 380 |
|
| 381 | |
| 382 | * drm_connector_init - Init a preallocated connector
|
| 383 | * @dev: DRM device
|
| 384 | * @connector: the connector to init
|
| 385 | * @funcs: callbacks for this connector
|
| 386 | * @connector_type: user visible type of the connector
|
| 387 | *
|
| 388 | * Initialises a preallocated connector. Connectors should be
|
| 389 | * subclassed as part of driver connector objects.
|
| 390 | *
|
| 391 | * At driver unload time the driver's &drm_connector_funcs.destroy hook
|
| 392 | * should call drm_connector_cleanup() and free the connector structure.
|
| 393 | * The connector structure should not be allocated with devm_kzalloc().
|
| 394 | *
|
| 395 | * Note: consider using drmm_connector_init() instead of
|
| 396 | * drm_connector_init() to let the DRM managed resource infrastructure
|
| 397 | * take care of cleanup and deallocation.
|
| 398 | *
|
| 399 | * Returns:
|
| 400 | * Zero on success, error code on failure.
|
| 401 |
|
| 402 | int drm_connector_init(struct drm_device *dev,
|
| 403 | struct drm_connector *connector,
|
| 404 | const struct drm_connector_funcs *funcs,
|
| 405 | int connector_type)
|
| 406 | {
|
| 407 | if (drm_WARN_ON(dev, !(funcs && funcs->destroy)))
|
| 408 | return -EINVAL;
|
| 409 |
|
| 410 | return drm_connector_init_and_add(dev, connector, funcs, connector_type, NULL);
|
| 411 | }
|
| 412 | EXPORT_SYMBOL(drm_connector_init);
|
| 413 |
|
| 414 | |
| 415 | * drm_connector_dynamic_init - Init a preallocated dynamic connector
|
| 416 | * @dev: DRM device
|
| 417 | * @connector: the connector to init
|
| 418 | * @funcs: callbacks for this connector
|
| 419 | * @connector_type: user visible type of the connector
|
| 420 | * @ddc: pointer to the associated ddc adapter
|
| 421 | *
|
| 422 | * Initialises a preallocated dynamic connector. Connectors should be
|
| 423 | * subclassed as part of driver connector objects. The connector
|
| 424 | * structure should not be allocated with devm_kzalloc().
|
| 425 | *
|
| 426 | * Drivers should call this for dynamic connectors which can be hotplugged
|
| 427 | * after drm_dev_register() has been called already, e.g. DP MST connectors.
|
| 428 | * For all other - static - connectors, drivers should call one of the
|
| 429 | * drm_connector_init*()/drmm_connector_init*() functions.
|
| 430 | *
|
| 431 | * After calling this function the drivers must call
|
| 432 | * drm_connector_dynamic_register().
|
| 433 | *
|
| 434 | * To remove the connector the driver must call drm_connector_unregister()
|
| 435 | * followed by drm_connector_put(). Putting the last reference will call the
|
| 436 | * driver's &drm_connector_funcs.destroy hook, which in turn must call
|
| 437 | * drm_connector_cleanup() and free the connector structure.
|
| 438 | *
|
| 439 | * Returns:
|
| 440 | * Zero on success, error code on failure.
|
| 441 |
|
| 442 | int drm_connector_dynamic_init(struct drm_device *dev,
|
| 443 | struct drm_connector *connector,
|
| 444 | const struct drm_connector_funcs *funcs,
|
| 445 | int connector_type,
|
| 446 | struct i2c_adapter *ddc)
|
| 447 | {
|
| 448 | if (drm_WARN_ON(dev, !(funcs && funcs->destroy)))
|
| 449 | return -EINVAL;
|
| 450 |
|
| 451 | return drm_connector_init_only(dev, connector, funcs, connector_type, ddc);
|
| 452 | }
|
| 453 | EXPORT_SYMBOL(drm_connector_dynamic_init);
|
| 454 |
|
| 455 | |
| 456 | * drm_connector_init_with_ddc - Init a preallocated connector
|
| 457 | * @dev: DRM device
|
| 458 | * @connector: the connector to init
|
| 459 | * @funcs: callbacks for this connector
|
| 460 | * @connector_type: user visible type of the connector
|
| 461 | * @ddc: pointer to the associated ddc adapter
|
| 462 | *
|
| 463 | * Initialises a preallocated connector. Connectors should be
|
| 464 | * subclassed as part of driver connector objects.
|
| 465 | *
|
| 466 | * At driver unload time the driver's &drm_connector_funcs.destroy hook
|
| 467 | * should call drm_connector_cleanup() and free the connector structure.
|
| 468 | * The connector structure should not be allocated with devm_kzalloc().
|
| 469 | *
|
| 470 | * Ensures that the ddc field of the connector is correctly set.
|
| 471 | *
|
| 472 | * Note: consider using drmm_connector_init() instead of
|
| 473 | * drm_connector_init_with_ddc() to let the DRM managed resource
|
| 474 | * infrastructure take care of cleanup and deallocation.
|
| 475 | *
|
| 476 | * Returns:
|
| 477 | * Zero on success, error code on failure.
|
| 478 |
|
| 479 | int drm_connector_init_with_ddc(struct drm_device *dev,
|
| 480 | struct drm_connector *connector,
|
| 481 | const struct drm_connector_funcs *funcs,
|
| 482 | int connector_type,
|
| 483 | struct i2c_adapter *ddc)
|
| 484 | {
|
| 485 | if (drm_WARN_ON(dev, !(funcs && funcs->destroy)))
|
| 486 | return -EINVAL;
|
| 487 |
|
| 488 | return drm_connector_init_and_add(dev, connector, funcs, connector_type, ddc);
|
| 489 | }
|
| 490 | EXPORT_SYMBOL(drm_connector_init_with_ddc);
|
| 491 |
|
| 492 | static void drm_connector_cleanup_action(struct drm_device *dev,
|
| 493 | void *ptr)
|
| 494 | {
|
| 495 | struct drm_connector *connector = ptr;
|
| 496 |
|
| 497 | drm_connector_cleanup(connector);
|
| 498 | }
|
| 499 |
|
| 500 | |
| 501 | * drmm_connector_init - Init a preallocated connector
|
| 502 | * @dev: DRM device
|
| 503 | * @connector: the connector to init
|
| 504 | * @funcs: callbacks for this connector
|
| 505 | * @connector_type: user visible type of the connector
|
| 506 | * @ddc: optional pointer to the associated ddc adapter
|
| 507 | *
|
| 508 | * Initialises a preallocated connector. Connectors should be
|
| 509 | * subclassed as part of driver connector objects.
|
| 510 | *
|
| 511 | * Cleanup is automatically handled with a call to
|
| 512 | * drm_connector_cleanup() in a DRM-managed action.
|
| 513 | *
|
| 514 | * The connector structure should be allocated with drmm_kzalloc().
|
| 515 | *
|
| 516 | * The @drm_connector_funcs.destroy hook must be NULL.
|
| 517 | *
|
| 518 | * Returns:
|
| 519 | * Zero on success, error code on failure.
|
| 520 |
|
| 521 | int drmm_connector_init(struct drm_device *dev,
|
| 522 | struct drm_connector *connector,
|
| 523 | const struct drm_connector_funcs *funcs,
|
| 524 | int connector_type,
|
| 525 | struct i2c_adapter *ddc)
|
| 526 | {
|
| 527 | int ret;
|
| 528 |
|
| 529 | if (drm_WARN_ON(dev, funcs && funcs->destroy))
|
| 530 | return -EINVAL;
|
| 531 |
|
| 532 | ret = drm_connector_init_and_add(dev, connector, funcs, connector_type, ddc);
|
| 533 | if (ret)
|
| 534 | return ret;
|
| 535 |
|
| 536 | ret = drmm_add_action_or_reset(dev, drm_connector_cleanup_action,
|
| 537 | connector);
|
| 538 | if (ret)
|
| 539 | return ret;
|
| 540 |
|
| 541 | return 0;
|
| 542 | }
|
| 543 | EXPORT_SYMBOL(drmm_connector_init);
|
| 544 |
|
| 545 | |
| 546 | * drmm_connector_hdmi_init - Init a preallocated HDMI connector
|
| 547 | * @dev: DRM device
|
| 548 | * @connector: A pointer to the HDMI connector to init
|
| 549 | * @vendor: HDMI Controller Vendor name
|
| 550 | * @product: HDMI Controller Product name
|
| 551 | * @funcs: callbacks for this connector
|
| 552 | * @hdmi_funcs: HDMI-related callbacks for this connector
|
| 553 | * @connector_type: user visible type of the connector
|
| 554 | * @ddc: optional pointer to the associated ddc adapter
|
| 555 | * @supported_formats: Bitmask of @drm_output_color_format listing supported output formats
|
| 556 | * @max_bpc: Maximum bits per char the HDMI connector supports
|
| 557 | *
|
| 558 | * Initialises a preallocated HDMI connector. Connectors can be
|
| 559 | * subclassed as part of driver connector objects.
|
| 560 | *
|
| 561 | * Cleanup is automatically handled with a call to
|
| 562 | * drm_connector_cleanup() in a DRM-managed action.
|
| 563 | *
|
| 564 | * The connector structure should be allocated with drmm_kzalloc().
|
| 565 | *
|
| 566 | * The @drm_connector_funcs.destroy hook must be NULL.
|
| 567 | *
|
| 568 | * Returns:
|
| 569 | * Zero on success, error code on failure.
|
| 570 |
|
| 571 | int drmm_connector_hdmi_init(struct drm_device *dev,
|
| 572 | struct drm_connector *connector,
|
| 573 | const char *vendor, const char *product,
|
| 574 | const struct drm_connector_funcs *funcs,
|
| 575 | const struct drm_connector_hdmi_funcs *hdmi_funcs,
|
| 576 | int connector_type,
|
| 577 | struct i2c_adapter *ddc,
|
| 578 | unsigned long supported_formats,
|
| 579 | unsigned int max_bpc)
|
| 580 | {
|
| 581 | int ret;
|
| 582 |
|
| 583 | if (!vendor || !product)
|
| 584 | return -EINVAL;
|
| 585 |
|
| 586 | if ((strlen(vendor) > DRM_CONNECTOR_HDMI_VENDOR_LEN) ||
|
| 587 | (strlen(product) > DRM_CONNECTOR_HDMI_PRODUCT_LEN))
|
| 588 | return -EINVAL;
|
| 589 |
|
| 590 | if (!(connector_type == DRM_MODE_CONNECTOR_HDMIA ||
|
| 591 | connector_type == DRM_MODE_CONNECTOR_HDMIB))
|
| 592 | return -EINVAL;
|
| 593 |
|
| 594 | if (!supported_formats || !(supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444)))
|
| 595 | return -EINVAL;
|
| 596 |
|
| 597 | if (connector->ycbcr_420_allowed != !!(supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420)))
|
| 598 | return -EINVAL;
|
| 599 |
|
| 600 | if (!(max_bpc == 8 || max_bpc == 10 || max_bpc == 12))
|
| 601 | return -EINVAL;
|
| 602 |
|
| 603 | if (!hdmi_funcs->avi.clear_infoframe ||
|
| 604 | !hdmi_funcs->avi.write_infoframe ||
|
| 605 | !hdmi_funcs->hdmi.clear_infoframe ||
|
| 606 | !hdmi_funcs->hdmi.write_infoframe)
|
| 607 | return -EINVAL;
|
| 608 |
|
| 609 | ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc);
|
| 610 | if (ret)
|
| 611 | return ret;
|
| 612 |
|
| 613 | connector->hdmi.supported_formats = supported_formats;
|
| 614 | strtomem_pad(connector->hdmi.vendor, vendor, 0);
|
| 615 | strtomem_pad(connector->hdmi.product, product, 0);
|
| 616 |
|
| 617 | |
| 618 | * drm_connector_attach_max_bpc_property() requires the
|
| 619 | * connector to have a state.
|
| 620 |
|
| 621 | if (connector->funcs->atomic_create_state) {
|
| 622 | struct drm_connector_state *state;
|
| 623 |
|
| 624 | state = connector->funcs->atomic_create_state(connector);
|
| 625 | if (IS_ERR(state))
|
| 626 | return PTR_ERR(state);
|
| 627 |
|
| 628 | connector->state = state;
|
| 629 | } else if (connector->funcs->reset) {
|
| 630 | connector->funcs->reset(connector);
|
| 631 | }
|
| 632 |
|
| 633 | drm_connector_attach_max_bpc_property(connector, 8, max_bpc);
|
| 634 | connector->max_bpc = max_bpc;
|
| 635 |
|
| 636 | if (max_bpc > 8)
|
| 637 | drm_connector_attach_hdr_output_metadata_property(connector);
|
| 638 |
|
| 639 | ret = drm_connector_attach_color_format_property(connector, supported_formats);
|
| 640 | if (ret)
|
| 641 | return ret;
|
| 642 |
|
| 643 | connector->hdmi.funcs = hdmi_funcs;
|
| 644 |
|
| 645 | return 0;
|
| 646 | }
|
| 647 | EXPORT_SYMBOL(drmm_connector_hdmi_init);
|
| 648 |
|
| 649 | |
| 650 | * drm_connector_attach_edid_property - attach edid property.
|
| 651 | * @connector: the connector
|
| 652 | *
|
| 653 | * Some connector types like DRM_MODE_CONNECTOR_VIRTUAL do not get a
|
| 654 | * edid property attached by default. This function can be used to
|
| 655 | * explicitly enable the edid property in these cases.
|
| 656 |
|
| 657 | void drm_connector_attach_edid_property(struct drm_connector *connector)
|
| 658 | {
|
| 659 | struct drm_mode_config *config = &connector->dev->mode_config;
|
| 660 |
|
| 661 | drm_object_attach_property(&connector->base,
|
| 662 | config->edid_property,
|
| 663 | 0);
|
| 664 | }
|
| 665 | EXPORT_SYMBOL(drm_connector_attach_edid_property);
|
| 666 |
|
| 667 | |
| 668 | * drm_connector_attach_encoder - attach a connector to an encoder
|
| 669 | * @connector: connector to attach
|
| 670 | * @encoder: encoder to attach @connector to
|
| 671 | *
|
| 672 | * This function links up a connector to an encoder. Note that the routing
|
| 673 | * restrictions between encoders and crtcs are exposed to userspace through the
|
| 674 | * possible_clones and possible_crtcs bitmasks.
|
| 675 | *
|
| 676 | * Returns:
|
| 677 | * Zero on success, negative errno on failure.
|
| 678 |
|
| 679 | int drm_connector_attach_encoder(struct drm_connector *connector,
|
| 680 | struct drm_encoder *encoder)
|
| 681 | {
|
| 682 | |
| 683 | * In the past, drivers have attempted to model the static association
|
| 684 | * of connector to encoder in simple connector/encoder devices using a
|
| 685 | * direct assignment of connector->encoder = encoder. This connection
|
| 686 | * is a logical one and the responsibility of the core, so drivers are
|
| 687 | * expected not to mess with this.
|
| 688 | *
|
| 689 | * Note that the error return should've been enough here, but a large
|
| 690 | * majority of drivers ignores the return value, so add in a big WARN
|
| 691 | * to get people's attention.
|
| 692 |
|
| 693 | if (WARN_ON(connector->encoder))
|
| 694 | return -EINVAL;
|
| 695 |
|
| 696 | connector->possible_encoders |= drm_encoder_mask(encoder);
|
| 697 |
|
| 698 | return 0;
|
| 699 | }
|
| 700 | EXPORT_SYMBOL(drm_connector_attach_encoder);
|
| 701 |
|
| 702 | |
| 703 | * drm_connector_has_possible_encoder - check if the connector and encoder are
|
| 704 | * associated with each other
|
| 705 | * @connector: the connector
|
| 706 | * @encoder: the encoder
|
| 707 | *
|
| 708 | * Returns:
|
| 709 | * True if @encoder is one of the possible encoders for @connector.
|
| 710 |
|
| 711 | bool drm_connector_has_possible_encoder(struct drm_connector *connector,
|
| 712 | struct drm_encoder *encoder)
|
| 713 | {
|
| 714 | return connector->possible_encoders & drm_encoder_mask(encoder);
|
| 715 | }
|
| 716 | EXPORT_SYMBOL(drm_connector_has_possible_encoder);
|
| 717 |
|
| 718 | static void drm_mode_remove(struct drm_connector *connector,
|
| 719 | struct drm_display_mode *mode)
|
| 720 | {
|
| 721 | list_del(&mode->head);
|
| 722 | drm_mode_destroy(connector->dev, mode);
|
| 723 | }
|
| 724 |
|
| 725 | |
| 726 | * drm_connector_cec_phys_addr_invalidate - invalidate CEC physical address
|
| 727 | * @connector: connector undergoing CEC operation
|
| 728 | *
|
| 729 | * Invalidated CEC physical address set for this DRM connector.
|
| 730 |
|
| 731 | void drm_connector_cec_phys_addr_invalidate(struct drm_connector *connector)
|
| 732 | {
|
| 733 | mutex_lock(&connector->cec.mutex);
|
| 734 |
|
| 735 | if (connector->cec.funcs &&
|
| 736 | connector->cec.funcs->phys_addr_invalidate)
|
| 737 | connector->cec.funcs->phys_addr_invalidate(connector);
|
| 738 |
|
| 739 | mutex_unlock(&connector->cec.mutex);
|
| 740 | }
|
| 741 | EXPORT_SYMBOL(drm_connector_cec_phys_addr_invalidate);
|
| 742 |
|
| 743 | |
| 744 | * drm_connector_cec_phys_addr_set - propagate CEC physical address
|
| 745 | * @connector: connector undergoing CEC operation
|
| 746 | *
|
| 747 | * Propagate CEC physical address from the display_info to this DRM connector.
|
| 748 |
|
| 749 | void drm_connector_cec_phys_addr_set(struct drm_connector *connector)
|
| 750 | {
|
| 751 | u16 addr;
|
| 752 |
|
| 753 | mutex_lock(&connector->cec.mutex);
|
| 754 |
|
| 755 | addr = connector->display_info.source_physical_address;
|
| 756 |
|
| 757 | if (connector->cec.funcs &&
|
| 758 | connector->cec.funcs->phys_addr_set)
|
| 759 | connector->cec.funcs->phys_addr_set(connector, addr);
|
| 760 |
|
| 761 | mutex_unlock(&connector->cec.mutex);
|
| 762 | }
|
| 763 | EXPORT_SYMBOL(drm_connector_cec_phys_addr_set);
|
| 764 |
|
| 765 | |
| 766 | * drm_connector_cleanup - cleans up an initialised connector
|
| 767 | * @connector: connector to cleanup
|
| 768 | *
|
| 769 | * Cleans up the connector but doesn't free the object.
|
| 770 |
|
| 771 | void drm_connector_cleanup(struct drm_connector *connector)
|
| 772 | {
|
| 773 | struct drm_device *dev = connector->dev;
|
| 774 | struct drm_display_mode *mode, *t;
|
| 775 |
|
| 776 | |
| 777 | * it is finally destroyed.
|
| 778 |
|
| 779 | if (WARN_ON(connector->registration_state ==
|
| 780 | DRM_CONNECTOR_REGISTERED))
|
| 781 | drm_connector_unregister(connector);
|
| 782 |
|
| 783 | platform_device_unregister(connector->hdmi_audio.codec_pdev);
|
| 784 |
|
| 785 | if (connector->privacy_screen) {
|
| 786 | drm_privacy_screen_put(connector->privacy_screen);
|
| 787 | connector->privacy_screen = NULL;
|
| 788 | }
|
| 789 |
|
| 790 | if (connector->tile_group) {
|
| 791 | drm_mode_put_tile_group(dev, connector->tile_group);
|
| 792 | connector->tile_group = NULL;
|
| 793 | }
|
| 794 |
|
| 795 | list_for_each_entry_safe(mode, t, &connector->probed_modes, head)
|
| 796 | drm_mode_remove(connector, mode);
|
| 797 |
|
| 798 | list_for_each_entry_safe(mode, t, &connector->modes, head)
|
| 799 | drm_mode_remove(connector, mode);
|
| 800 |
|
| 801 | ida_free(&drm_connector_enum_list[connector->connector_type].ida,
|
| 802 | connector->connector_type_id);
|
| 803 |
|
| 804 | ida_free(&dev->mode_config.connector_ida, connector->index);
|
| 805 |
|
| 806 | kfree(connector->display_info.bus_formats);
|
| 807 | kfree(connector->display_info.vics);
|
| 808 | drm_mode_object_unregister(dev, &connector->base);
|
| 809 | kfree(connector->name);
|
| 810 | connector->name = NULL;
|
| 811 | fwnode_handle_put(connector->fwnode);
|
| 812 | connector->fwnode = NULL;
|
| 813 |
|
| 814 | drm_connector_remove(connector);
|
| 815 |
|
| 816 | WARN_ON(connector->state && !connector->funcs->atomic_destroy_state);
|
| 817 | if (connector->state && connector->funcs->atomic_destroy_state)
|
| 818 | connector->funcs->atomic_destroy_state(connector,
|
| 819 | connector->state);
|
| 820 |
|
| 821 | mutex_destroy(&connector->hdmi_audio.lock);
|
| 822 | mutex_destroy(&connector->hdmi.infoframes.lock);
|
| 823 | mutex_destroy(&connector->mutex);
|
| 824 |
|
| 825 | memset(connector, 0, sizeof(*connector));
|
| 826 |
|
| 827 | if (dev->registered)
|
| 828 | drm_sysfs_hotplug_event(dev);
|
| 829 | }
|
| 830 | EXPORT_SYMBOL(drm_connector_cleanup);
|
| 831 |
|
| 832 | |
| 833 | * drm_connector_register - register a connector
|
| 834 | * @connector: the connector to register
|
| 835 | *
|
| 836 | * Register userspace interfaces for a connector. Drivers shouldn't call this
|
| 837 | * function. Static connectors will be registered automatically by DRM core
|
| 838 | * from drm_dev_register(), dynamic connectors (MST) should be registered by
|
| 839 | * drivers calling drm_connector_dynamic_register().
|
| 840 | *
|
| 841 | * When the connector is no longer available, callers must call
|
| 842 | * drm_connector_unregister().
|
| 843 | *
|
| 844 | * Note: Existing uses of this function in drivers should be a nop already and
|
| 845 | * are scheduled to be removed.
|
| 846 | *
|
| 847 | * Returns:
|
| 848 | * Zero on success, error code on failure.
|
| 849 |
|
| 850 | int drm_connector_register(struct drm_connector *connector)
|
| 851 | {
|
| 852 | int ret = 0;
|
| 853 |
|
| 854 | if (!connector->dev->registered)
|
| 855 | return 0;
|
| 856 |
|
| 857 | mutex_lock(&connector->mutex);
|
| 858 | if (connector->registration_state != DRM_CONNECTOR_INITIALIZING)
|
| 859 | goto unlock;
|
| 860 |
|
| 861 | ret = drm_sysfs_connector_add(connector);
|
| 862 | if (ret)
|
| 863 | goto unlock;
|
| 864 |
|
| 865 | drm_debugfs_connector_add(connector);
|
| 866 |
|
| 867 | if (connector->funcs->late_register) {
|
| 868 | ret = connector->funcs->late_register(connector);
|
| 869 | if (ret)
|
| 870 | goto err_debugfs;
|
| 871 | }
|
| 872 |
|
| 873 | ret = drm_sysfs_connector_add_late(connector);
|
| 874 | if (ret)
|
| 875 | goto err_late_register;
|
| 876 |
|
| 877 | drm_mode_object_register(connector->dev, &connector->base);
|
| 878 |
|
| 879 | connector->registration_state = DRM_CONNECTOR_REGISTERED;
|
| 880 |
|
| 881 |
|
| 882 | drm_sysfs_connector_hotplug_event(connector);
|
| 883 |
|
| 884 | if (connector->privacy_screen)
|
| 885 | drm_privacy_screen_register_notifier(connector->privacy_screen,
|
| 886 | &connector->privacy_screen_notifier);
|
| 887 |
|
| 888 | mutex_lock(&connector_list_lock);
|
| 889 | list_add_tail(&connector->global_connector_list_entry, &connector_list);
|
| 890 | mutex_unlock(&connector_list_lock);
|
| 891 | goto unlock;
|
| 892 |
|
| 893 | err_late_register:
|
| 894 | if (connector->funcs->early_unregister)
|
| 895 | connector->funcs->early_unregister(connector);
|
| 896 | err_debugfs:
|
| 897 | drm_debugfs_connector_remove(connector);
|
| 898 | drm_sysfs_connector_remove(connector);
|
| 899 | unlock:
|
| 900 | mutex_unlock(&connector->mutex);
|
| 901 | return ret;
|
| 902 | }
|
| 903 | EXPORT_SYMBOL(drm_connector_register);
|
| 904 |
|
| 905 | |
| 906 | * drm_connector_dynamic_register - register a dynamic connector
|
| 907 | * @connector: the connector to register
|
| 908 | *
|
| 909 | * Register userspace interfaces for a connector. Only call this for connectors
|
| 910 | * initialized by calling drm_connector_dynamic_init(). All other connectors
|
| 911 | * will be registered automatically when calling drm_dev_register().
|
| 912 | *
|
| 913 | * When the connector is no longer available the driver must call
|
| 914 | * drm_connector_unregister().
|
| 915 | *
|
| 916 | * Returns:
|
| 917 | * Zero on success, error code on failure.
|
| 918 |
|
| 919 | int drm_connector_dynamic_register(struct drm_connector *connector)
|
| 920 | {
|
| 921 |
|
| 922 | if (WARN_ON(!(connector->funcs && connector->funcs->destroy)))
|
| 923 | return -EINVAL;
|
| 924 |
|
| 925 | drm_connector_add(connector);
|
| 926 |
|
| 927 | return drm_connector_register(connector);
|
| 928 | }
|
| 929 | EXPORT_SYMBOL(drm_connector_dynamic_register);
|
| 930 |
|
| 931 | |
| 932 | * drm_connector_unregister - unregister a connector
|
| 933 | * @connector: the connector to unregister
|
| 934 | *
|
| 935 | * Unregister userspace interfaces for a connector. Drivers should call this
|
| 936 | * for dynamic connectors (MST) only, which were registered explicitly by
|
| 937 | * calling drm_connector_dynamic_register(). All other - static - connectors
|
| 938 | * will be unregistered automatically by DRM core and drivers shouldn't call
|
| 939 | * this function for those.
|
| 940 | *
|
| 941 | * Note: Existing uses of this function in drivers for static connectors
|
| 942 | * should be a nop already and are scheduled to be removed.
|
| 943 |
|
| 944 | void drm_connector_unregister(struct drm_connector *connector)
|
| 945 | {
|
| 946 | mutex_lock(&connector->mutex);
|
| 947 | if (connector->registration_state != DRM_CONNECTOR_REGISTERED) {
|
| 948 | mutex_unlock(&connector->mutex);
|
| 949 | return;
|
| 950 | }
|
| 951 |
|
| 952 | mutex_lock(&connector_list_lock);
|
| 953 | list_del_init(&connector->global_connector_list_entry);
|
| 954 | mutex_unlock(&connector_list_lock);
|
| 955 |
|
| 956 | if (connector->privacy_screen)
|
| 957 | drm_privacy_screen_unregister_notifier(
|
| 958 | connector->privacy_screen,
|
| 959 | &connector->privacy_screen_notifier);
|
| 960 |
|
| 961 | drm_sysfs_connector_remove_early(connector);
|
| 962 |
|
| 963 | if (connector->funcs->early_unregister)
|
| 964 | connector->funcs->early_unregister(connector);
|
| 965 |
|
| 966 | drm_debugfs_connector_remove(connector);
|
| 967 | drm_sysfs_connector_remove(connector);
|
| 968 |
|
| 969 | connector->registration_state = DRM_CONNECTOR_UNREGISTERED;
|
| 970 | mutex_unlock(&connector->mutex);
|
| 971 | }
|
| 972 | EXPORT_SYMBOL(drm_connector_unregister);
|
| 973 |
|
| 974 | void drm_connector_unregister_all(struct drm_device *dev)
|
| 975 | {
|
| 976 | struct drm_connector *connector;
|
| 977 | struct drm_connector_list_iter conn_iter;
|
| 978 |
|
| 979 | drm_connector_list_iter_begin(dev, &conn_iter);
|
| 980 | drm_for_each_connector_iter(connector, &conn_iter)
|
| 981 | drm_connector_unregister(connector);
|
| 982 | drm_connector_list_iter_end(&conn_iter);
|
| 983 | }
|
| 984 |
|
| 985 | int drm_connector_register_all(struct drm_device *dev)
|
| 986 | {
|
| 987 | struct drm_connector *connector;
|
| 988 | struct drm_connector_list_iter conn_iter;
|
| 989 | int ret = 0;
|
| 990 |
|
| 991 | drm_connector_list_iter_begin(dev, &conn_iter);
|
| 992 | drm_for_each_connector_iter(connector, &conn_iter) {
|
| 993 | ret = drm_connector_register(connector);
|
| 994 | if (ret)
|
| 995 | break;
|
| 996 | }
|
| 997 | drm_connector_list_iter_end(&conn_iter);
|
| 998 |
|
| 999 | if (ret)
|
| 1000 | drm_connector_unregister_all(dev);
|
| 1001 | return ret;
|
| 1002 | }
|
| 1003 |
|
| 1004 | |
| 1005 | * drm_get_connector_status_name - return a string for connector status
|
| 1006 | * @status: connector status to compute name of
|
| 1007 | *
|
| 1008 | * In contrast to the other drm_get_*_name functions this one here returns a
|
| 1009 | * const pointer and hence is threadsafe.
|
| 1010 | *
|
| 1011 | * Returns: connector status string
|
| 1012 |
|
| 1013 | const char *drm_get_connector_status_name(enum drm_connector_status status)
|
| 1014 | {
|
| 1015 | if (status == connector_status_connected)
|
| 1016 | return "connected";
|
| 1017 | else if (status == connector_status_disconnected)
|
| 1018 | return "disconnected";
|
| 1019 | else
|
| 1020 | return "unknown";
|
| 1021 | }
|
| 1022 | EXPORT_SYMBOL(drm_get_connector_status_name);
|
| 1023 |
|
| 1024 | |
| 1025 | * drm_get_connector_force_name - return a string for connector force
|
| 1026 | * @force: connector force to get name of
|
| 1027 | *
|
| 1028 | * Returns: const pointer to name.
|
| 1029 |
|
| 1030 | const char *drm_get_connector_force_name(enum drm_connector_force force)
|
| 1031 | {
|
| 1032 | switch (force) {
|
| 1033 | case DRM_FORCE_UNSPECIFIED:
|
| 1034 | return "unspecified";
|
| 1035 | case DRM_FORCE_OFF:
|
| 1036 | return "off";
|
| 1037 | case DRM_FORCE_ON:
|
| 1038 | return "on";
|
| 1039 | case DRM_FORCE_ON_DIGITAL:
|
| 1040 | return "digital";
|
| 1041 | default:
|
| 1042 | return "unknown";
|
| 1043 | }
|
| 1044 | }
|
| 1045 |
|
| 1046 | #ifdef CONFIG_LOCKDEP
|
| 1047 | static struct lockdep_map connector_list_iter_dep_map = {
|
| 1048 | .name = "drm_connector_list_iter"
|
| 1049 | };
|
| 1050 | #endif
|
| 1051 |
|
| 1052 | |
| 1053 | * drm_connector_list_iter_begin - initialize a connector_list iterator
|
| 1054 | * @dev: DRM device
|
| 1055 | * @iter: connector_list iterator
|
| 1056 | *
|
| 1057 | * Sets @iter up to walk the &drm_mode_config.connector_list of @dev. @iter
|
| 1058 | * must always be cleaned up again by calling drm_connector_list_iter_end().
|
| 1059 | * Iteration itself happens using drm_connector_list_iter_next() or
|
| 1060 | * drm_for_each_connector_iter().
|
| 1061 |
|
| 1062 | void drm_connector_list_iter_begin(struct drm_device *dev,
|
| 1063 | struct drm_connector_list_iter *iter)
|
| 1064 | {
|
| 1065 | iter->dev = dev;
|
| 1066 | iter->conn = NULL;
|
| 1067 | lock_acquire_shared_recursive(&connector_list_iter_dep_map, 0, 1, NULL, _RET_IP_);
|
| 1068 | }
|
| 1069 | EXPORT_SYMBOL(drm_connector_list_iter_begin);
|
| 1070 |
|
| 1071 | |
| 1072 | * Extra-safe connector put function that works in any context. Should only be
|
| 1073 | * used from the connector_iter functions, where we never really expect to
|
| 1074 | * actually release the connector when dropping our final reference.
|
| 1075 |
|
| 1076 | static void
|
| 1077 | __drm_connector_put_safe(struct drm_connector *conn)
|
| 1078 | {
|
| 1079 | struct drm_mode_config *config = &conn->dev->mode_config;
|
| 1080 |
|
| 1081 | lockdep_assert_held(&config->connector_list_lock);
|
| 1082 |
|
| 1083 | if (!refcount_dec_and_test(&conn->base.refcount.refcount))
|
| 1084 | return;
|
| 1085 |
|
| 1086 | llist_add(&conn->free_node, &config->connector_free_list);
|
| 1087 | schedule_work(&config->connector_free_work);
|
| 1088 | }
|
| 1089 |
|
| 1090 | |
| 1091 | * drm_connector_list_iter_next - return next connector
|
| 1092 | * @iter: connector_list iterator
|
| 1093 | *
|
| 1094 | * Returns: the next connector for @iter, or NULL when the list walk has
|
| 1095 | * completed.
|
| 1096 |
|
| 1097 | struct drm_connector *
|
| 1098 | drm_connector_list_iter_next(struct drm_connector_list_iter *iter)
|
| 1099 | {
|
| 1100 | struct drm_connector *old_conn = iter->conn;
|
| 1101 | struct drm_mode_config *config = &iter->dev->mode_config;
|
| 1102 | struct list_head *lhead;
|
| 1103 | unsigned long flags;
|
| 1104 |
|
| 1105 | spin_lock_irqsave(&config->connector_list_lock, flags);
|
| 1106 | lhead = old_conn ? &old_conn->head : &config->connector_list;
|
| 1107 |
|
| 1108 | do {
|
| 1109 | if (lhead->next == &config->connector_list) {
|
| 1110 | iter->conn = NULL;
|
| 1111 | break;
|
| 1112 | }
|
| 1113 |
|
| 1114 | lhead = lhead->next;
|
| 1115 | iter->conn = list_entry(lhead, struct drm_connector, head);
|
| 1116 |
|
| 1117 |
|
| 1118 | } while (!kref_get_unless_zero(&iter->conn->base.refcount));
|
| 1119 |
|
| 1120 | if (old_conn)
|
| 1121 | __drm_connector_put_safe(old_conn);
|
| 1122 | spin_unlock_irqrestore(&config->connector_list_lock, flags);
|
| 1123 |
|
| 1124 | return iter->conn;
|
| 1125 | }
|
| 1126 | EXPORT_SYMBOL(drm_connector_list_iter_next);
|
| 1127 |
|
| 1128 | |
| 1129 | * drm_connector_list_iter_end - tear down a connector_list iterator
|
| 1130 | * @iter: connector_list iterator
|
| 1131 | *
|
| 1132 | * Tears down @iter and releases any resources (like &drm_connector references)
|
| 1133 | * acquired while walking the list. This must always be called, both when the
|
| 1134 | * iteration completes fully or when it was aborted without walking the entire
|
| 1135 | * list.
|
| 1136 |
|
| 1137 | void drm_connector_list_iter_end(struct drm_connector_list_iter *iter)
|
| 1138 | {
|
| 1139 | struct drm_mode_config *config = &iter->dev->mode_config;
|
| 1140 | unsigned long flags;
|
| 1141 |
|
| 1142 | iter->dev = NULL;
|
| 1143 | if (iter->conn) {
|
| 1144 | spin_lock_irqsave(&config->connector_list_lock, flags);
|
| 1145 | __drm_connector_put_safe(iter->conn);
|
| 1146 | spin_unlock_irqrestore(&config->connector_list_lock, flags);
|
| 1147 | }
|
| 1148 | lock_release(&connector_list_iter_dep_map, _RET_IP_);
|
| 1149 | }
|
| 1150 | EXPORT_SYMBOL(drm_connector_list_iter_end);
|
| 1151 |
|
| 1152 | static const struct drm_prop_enum_list drm_subpixel_enum_list[] = {
|
| 1153 | { SubPixelUnknown, "Unknown" },
|
| 1154 | { SubPixelHorizontalRGB, "Horizontal RGB" },
|
| 1155 | { SubPixelHorizontalBGR, "Horizontal BGR" },
|
| 1156 | { SubPixelVerticalRGB, "Vertical RGB" },
|
| 1157 | { SubPixelVerticalBGR, "Vertical BGR" },
|
| 1158 | { SubPixelNone, "None" },
|
| 1159 | };
|
| 1160 |
|
| 1161 | |
| 1162 | * drm_get_subpixel_order_name - return a string for a given subpixel enum
|
| 1163 | * @order: enum of subpixel_order
|
| 1164 | *
|
| 1165 | * Note you could abuse this and return something out of bounds, but that
|
| 1166 | * would be a caller error. No unscrubbed user data should make it here.
|
| 1167 | *
|
| 1168 | * Returns: string describing an enumerated subpixel property
|
| 1169 |
|
| 1170 | const char *drm_get_subpixel_order_name(enum subpixel_order order)
|
| 1171 | {
|
| 1172 | return drm_subpixel_enum_list[order].name;
|
| 1173 | }
|
| 1174 | EXPORT_SYMBOL(drm_get_subpixel_order_name);
|
| 1175 |
|
| 1176 | static const struct drm_prop_enum_list drm_dpms_enum_list[] = {
|
| 1177 | { DRM_MODE_DPMS_ON, "On" },
|
| 1178 | { DRM_MODE_DPMS_STANDBY, "Standby" },
|
| 1179 | { DRM_MODE_DPMS_SUSPEND, "Suspend" },
|
| 1180 | { DRM_MODE_DPMS_OFF, "Off" }
|
| 1181 | };
|
| 1182 | DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
|
| 1183 |
|
| 1184 | static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
|
| 1185 | { DRM_MODE_LINK_STATUS_GOOD, "Good" },
|
| 1186 | { DRM_MODE_LINK_STATUS_BAD, "Bad" },
|
| 1187 | };
|
| 1188 |
|
| 1189 | static const struct drm_prop_enum_list drm_panel_type_enum_list[] = {
|
| 1190 | { DRM_MODE_PANEL_TYPE_UNKNOWN, "unknown" },
|
| 1191 | { DRM_MODE_PANEL_TYPE_OLED, "OLED" },
|
| 1192 | { DRM_MODE_PANEL_TYPE_LCD, "LCD" },
|
| 1193 | };
|
| 1194 |
|
| 1195 | |
| 1196 | * drm_display_info_set_bus_formats - set the supported bus formats
|
| 1197 | * @info: display info to store bus formats in
|
| 1198 | * @formats: array containing the supported bus formats
|
| 1199 | * @num_formats: the number of entries in the fmts array
|
| 1200 | *
|
| 1201 | * Store the supported bus formats in display info structure.
|
| 1202 | * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for
|
| 1203 | * a full list of available formats.
|
| 1204 | *
|
| 1205 | * Returns:
|
| 1206 | * 0 on success or a negative error code on failure.
|
| 1207 |
|
| 1208 | int drm_display_info_set_bus_formats(struct drm_display_info *info,
|
| 1209 | const u32 *formats,
|
| 1210 | unsigned int num_formats)
|
| 1211 | {
|
| 1212 | u32 *fmts = NULL;
|
| 1213 |
|
| 1214 | if (!formats && num_formats)
|
| 1215 | return -EINVAL;
|
| 1216 |
|
| 1217 | if (formats && num_formats) {
|
| 1218 | fmts = kmemdup(formats, sizeof(*formats) * num_formats,
|
| 1219 | GFP_KERNEL);
|
| 1220 | if (!fmts)
|
| 1221 | return -ENOMEM;
|
| 1222 | }
|
| 1223 |
|
| 1224 | kfree(info->bus_formats);
|
| 1225 | info->bus_formats = fmts;
|
| 1226 | info->num_bus_formats = num_formats;
|
| 1227 |
|
| 1228 | return 0;
|
| 1229 | }
|
| 1230 | EXPORT_SYMBOL(drm_display_info_set_bus_formats);
|
| 1231 |
|
| 1232 |
|
| 1233 | static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = {
|
| 1234 | { DRM_MODE_SCALE_NONE, "None" },
|
| 1235 | { DRM_MODE_SCALE_FULLSCREEN, "Full" },
|
| 1236 | { DRM_MODE_SCALE_CENTER, "Center" },
|
| 1237 | { DRM_MODE_SCALE_ASPECT, "Full aspect" },
|
| 1238 | };
|
| 1239 |
|
| 1240 | static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = {
|
| 1241 | { DRM_MODE_PICTURE_ASPECT_NONE, "Automatic" },
|
| 1242 | { DRM_MODE_PICTURE_ASPECT_4_3, "4:3" },
|
| 1243 | { DRM_MODE_PICTURE_ASPECT_16_9, "16:9" },
|
| 1244 | };
|
| 1245 |
|
| 1246 | static const struct drm_prop_enum_list drm_content_type_enum_list[] = {
|
| 1247 | { DRM_MODE_CONTENT_TYPE_NO_DATA, "No Data" },
|
| 1248 | { DRM_MODE_CONTENT_TYPE_GRAPHICS, "Graphics" },
|
| 1249 | { DRM_MODE_CONTENT_TYPE_PHOTO, "Photo" },
|
| 1250 | { DRM_MODE_CONTENT_TYPE_CINEMA, "Cinema" },
|
| 1251 | { DRM_MODE_CONTENT_TYPE_GAME, "Game" },
|
| 1252 | };
|
| 1253 |
|
| 1254 | static const struct drm_prop_enum_list drm_panel_orientation_enum_list[] = {
|
| 1255 | { DRM_MODE_PANEL_ORIENTATION_NORMAL, "Normal" },
|
| 1256 | { DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP, "Upside Down" },
|
| 1257 | { DRM_MODE_PANEL_ORIENTATION_LEFT_UP, "Left Side Up" },
|
| 1258 | { DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, "Right Side Up" },
|
| 1259 | };
|
| 1260 |
|
| 1261 | static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = {
|
| 1262 | { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" },
|
| 1263 | { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" },
|
| 1264 | { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" },
|
| 1265 | };
|
| 1266 | DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
|
| 1267 |
|
| 1268 | static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = {
|
| 1269 | { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" },
|
| 1270 | { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" },
|
| 1271 | { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" },
|
| 1272 | };
|
| 1273 | DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name,
|
| 1274 | drm_dvi_i_subconnector_enum_list)
|
| 1275 |
|
| 1276 | static const struct drm_prop_enum_list drm_tv_mode_enum_list[] = {
|
| 1277 | { DRM_MODE_TV_MODE_NTSC, "NTSC" },
|
| 1278 | { DRM_MODE_TV_MODE_NTSC_443, "NTSC-443" },
|
| 1279 | { DRM_MODE_TV_MODE_NTSC_J, "NTSC-J" },
|
| 1280 | { DRM_MODE_TV_MODE_PAL, "PAL" },
|
| 1281 | { DRM_MODE_TV_MODE_PAL_M, "PAL-M" },
|
| 1282 | { DRM_MODE_TV_MODE_PAL_N, "PAL-N" },
|
| 1283 | { DRM_MODE_TV_MODE_SECAM, "SECAM" },
|
| 1284 | { DRM_MODE_TV_MODE_MONOCHROME, "Mono" },
|
| 1285 | };
|
| 1286 | DRM_ENUM_NAME_FN(drm_get_tv_mode_name, drm_tv_mode_enum_list)
|
| 1287 |
|
| 1288 | |
| 1289 | * drm_get_tv_mode_from_name - Translates a TV mode name into its enum value
|
| 1290 | * @name: TV Mode name we want to convert
|
| 1291 | * @len: Length of @name
|
| 1292 | *
|
| 1293 | * Translates @name into an enum drm_connector_tv_mode.
|
| 1294 | *
|
| 1295 | * Returns: the enum value on success, a negative errno otherwise.
|
| 1296 |
|
| 1297 | int drm_get_tv_mode_from_name(const char *name, size_t len)
|
| 1298 | {
|
| 1299 | unsigned int i;
|
| 1300 |
|
| 1301 | for (i = 0; i < ARRAY_SIZE(drm_tv_mode_enum_list); i++) {
|
| 1302 | const struct drm_prop_enum_list *item = &drm_tv_mode_enum_list[i];
|
| 1303 |
|
| 1304 | if (strlen(item->name) == len && !strncmp(item->name, name, len))
|
| 1305 | return item->type;
|
| 1306 | }
|
| 1307 |
|
| 1308 | return -EINVAL;
|
| 1309 | }
|
| 1310 | EXPORT_SYMBOL(drm_get_tv_mode_from_name);
|
| 1311 |
|
| 1312 | static const struct drm_prop_enum_list drm_tv_select_enum_list[] = {
|
| 1313 | { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" },
|
| 1314 | { DRM_MODE_SUBCONNECTOR_Composite, "Composite" },
|
| 1315 | { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" },
|
| 1316 | { DRM_MODE_SUBCONNECTOR_Component, "Component" },
|
| 1317 | { DRM_MODE_SUBCONNECTOR_SCART, "SCART" },
|
| 1318 | };
|
| 1319 | DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
|
| 1320 |
|
| 1321 | static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
|
| 1322 | { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" },
|
| 1323 | { DRM_MODE_SUBCONNECTOR_Composite, "Composite" },
|
| 1324 | { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" },
|
| 1325 | { DRM_MODE_SUBCONNECTOR_Component, "Component" },
|
| 1326 | { DRM_MODE_SUBCONNECTOR_SCART, "SCART" },
|
| 1327 | };
|
| 1328 | DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
|
| 1329 | drm_tv_subconnector_enum_list)
|
| 1330 |
|
| 1331 | static const struct drm_prop_enum_list drm_dp_subconnector_enum_list[] = {
|
| 1332 | { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" },
|
| 1333 | { DRM_MODE_SUBCONNECTOR_VGA, "VGA" },
|
| 1334 | { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" },
|
| 1335 | { DRM_MODE_SUBCONNECTOR_HDMIA, "HDMI" },
|
| 1336 | { DRM_MODE_SUBCONNECTOR_DisplayPort, "DP" },
|
| 1337 | { DRM_MODE_SUBCONNECTOR_Wireless, "Wireless" },
|
| 1338 | { DRM_MODE_SUBCONNECTOR_Native, "Native" },
|
| 1339 | };
|
| 1340 |
|
| 1341 | DRM_ENUM_NAME_FN(drm_get_dp_subconnector_name,
|
| 1342 | drm_dp_subconnector_enum_list)
|
| 1343 |
|
| 1344 |
|
| 1345 | static const char * const colorspace_names[] = {
|
| 1346 |
|
| 1347 | [DRM_MODE_COLORIMETRY_DEFAULT] = "Default",
|
| 1348 |
|
| 1349 | [DRM_MODE_COLORIMETRY_SMPTE_170M_YCC] = "SMPTE_170M_YCC",
|
| 1350 | [DRM_MODE_COLORIMETRY_BT709_YCC] = "BT709_YCC",
|
| 1351 |
|
| 1352 | [DRM_MODE_COLORIMETRY_XVYCC_601] = "XVYCC_601",
|
| 1353 |
|
| 1354 | [DRM_MODE_COLORIMETRY_XVYCC_709] = "XVYCC_709",
|
| 1355 |
|
| 1356 | [DRM_MODE_COLORIMETRY_SYCC_601] = "SYCC_601",
|
| 1357 |
|
| 1358 | [DRM_MODE_COLORIMETRY_OPYCC_601] = "opYCC_601",
|
| 1359 |
|
| 1360 | [DRM_MODE_COLORIMETRY_OPRGB] = "opRGB",
|
| 1361 |
|
| 1362 | [DRM_MODE_COLORIMETRY_BT2020_CYCC] = "BT2020_CYCC",
|
| 1363 |
|
| 1364 | [DRM_MODE_COLORIMETRY_BT2020_RGB] = "BT2020_RGB",
|
| 1365 |
|
| 1366 | [DRM_MODE_COLORIMETRY_BT2020_YCC] = "BT2020_YCC",
|
| 1367 |
|
| 1368 | [DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65] = "DCI-P3_RGB_D65",
|
| 1369 | [DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER] = "DCI-P3_RGB_Theater",
|
| 1370 | [DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED] = "RGB_WIDE_FIXED",
|
| 1371 |
|
| 1372 | [DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT] = "RGB_WIDE_FLOAT",
|
| 1373 | [DRM_MODE_COLORIMETRY_BT601_YCC] = "BT601_YCC",
|
| 1374 | };
|
| 1375 |
|
| 1376 | |
| 1377 | * drm_get_colorspace_name - return a string for color encoding
|
| 1378 | * @colorspace: color space to compute name of
|
| 1379 | *
|
| 1380 | * In contrast to the other drm_get_*_name functions this one here returns a
|
| 1381 | * const pointer and hence is threadsafe.
|
| 1382 |
|
| 1383 | const char *drm_get_colorspace_name(enum drm_colorspace colorspace)
|
| 1384 | {
|
| 1385 | if (colorspace < ARRAY_SIZE(colorspace_names) && colorspace_names[colorspace])
|
| 1386 | return colorspace_names[colorspace];
|
| 1387 | else
|
| 1388 | return "(null)";
|
| 1389 | }
|
| 1390 |
|
| 1391 | static const u32 hdmi_colorspaces =
|
| 1392 | BIT(DRM_MODE_COLORIMETRY_SMPTE_170M_YCC) |
|
| 1393 | BIT(DRM_MODE_COLORIMETRY_BT709_YCC) |
|
| 1394 | BIT(DRM_MODE_COLORIMETRY_XVYCC_601) |
|
| 1395 | BIT(DRM_MODE_COLORIMETRY_XVYCC_709) |
|
| 1396 | BIT(DRM_MODE_COLORIMETRY_SYCC_601) |
|
| 1397 | BIT(DRM_MODE_COLORIMETRY_OPYCC_601) |
|
| 1398 | BIT(DRM_MODE_COLORIMETRY_OPRGB) |
|
| 1399 | BIT(DRM_MODE_COLORIMETRY_BT2020_CYCC) |
|
| 1400 | BIT(DRM_MODE_COLORIMETRY_BT2020_RGB) |
|
| 1401 | BIT(DRM_MODE_COLORIMETRY_BT2020_YCC) |
|
| 1402 | BIT(DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65) |
|
| 1403 | BIT(DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER);
|
| 1404 |
|
| 1405 | static const u32 hdmi_colorformats =
|
| 1406 | BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444) |
|
| 1407 | BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444) |
|
| 1408 | BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422) |
|
| 1409 | BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420);
|
| 1410 |
|
| 1411 | static const u32 dp_colorformats =
|
| 1412 | BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444) |
|
| 1413 | BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444) |
|
| 1414 | BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422) |
|
| 1415 | BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420);
|
| 1416 |
|
| 1417 | |
| 1418 | * As per DP 1.4a spec, 2.2.5.7.5 VSC SDP Payload for Pixel Encoding/Colorimetry
|
| 1419 | * Format Table 2-120
|
| 1420 |
|
| 1421 | static const u32 dp_colorspaces =
|
| 1422 | BIT(DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED) |
|
| 1423 | BIT(DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT) |
|
| 1424 | BIT(DRM_MODE_COLORIMETRY_OPRGB) |
|
| 1425 | BIT(DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65) |
|
| 1426 | BIT(DRM_MODE_COLORIMETRY_BT2020_RGB) |
|
| 1427 | BIT(DRM_MODE_COLORIMETRY_BT601_YCC) |
|
| 1428 | BIT(DRM_MODE_COLORIMETRY_BT709_YCC) |
|
| 1429 | BIT(DRM_MODE_COLORIMETRY_XVYCC_601) |
|
| 1430 | BIT(DRM_MODE_COLORIMETRY_XVYCC_709) |
|
| 1431 | BIT(DRM_MODE_COLORIMETRY_SYCC_601) |
|
| 1432 | BIT(DRM_MODE_COLORIMETRY_OPYCC_601) |
|
| 1433 | BIT(DRM_MODE_COLORIMETRY_BT2020_CYCC) |
|
| 1434 | BIT(DRM_MODE_COLORIMETRY_BT2020_YCC);
|
| 1435 |
|
| 1436 | static const struct drm_prop_enum_list broadcast_rgb_names[] = {
|
| 1437 | { DRM_HDMI_BROADCAST_RGB_AUTO, "Automatic" },
|
| 1438 | { DRM_HDMI_BROADCAST_RGB_FULL, "Full" },
|
| 1439 | { DRM_HDMI_BROADCAST_RGB_LIMITED, "Limited 16:235" },
|
| 1440 | };
|
| 1441 |
|
| 1442 | |
| 1443 | * drm_hdmi_connector_get_broadcast_rgb_name - Return a string for HDMI connector RGB broadcast selection
|
| 1444 | * @broadcast_rgb: Broadcast RGB selection to compute name of
|
| 1445 | *
|
| 1446 | * Returns: the name of the Broadcast RGB selection, or NULL if the type
|
| 1447 | * is not valid.
|
| 1448 |
|
| 1449 | const char *
|
| 1450 | drm_hdmi_connector_get_broadcast_rgb_name(enum drm_hdmi_broadcast_rgb broadcast_rgb)
|
| 1451 | {
|
| 1452 | if (broadcast_rgb >= ARRAY_SIZE(broadcast_rgb_names))
|
| 1453 | return NULL;
|
| 1454 |
|
| 1455 | return broadcast_rgb_names[broadcast_rgb].name;
|
| 1456 | }
|
| 1457 | EXPORT_SYMBOL(drm_hdmi_connector_get_broadcast_rgb_name);
|
| 1458 |
|
| 1459 | static const char * const output_format_str[] = {
|
| 1460 | [DRM_OUTPUT_COLOR_FORMAT_RGB444] = "RGB",
|
| 1461 | [DRM_OUTPUT_COLOR_FORMAT_YCBCR420] = "YUV 4:2:0",
|
| 1462 | [DRM_OUTPUT_COLOR_FORMAT_YCBCR422] = "YUV 4:2:2",
|
| 1463 | [DRM_OUTPUT_COLOR_FORMAT_YCBCR444] = "YUV 4:4:4",
|
| 1464 | };
|
| 1465 |
|
| 1466 | |
| 1467 | * drm_hdmi_connector_get_output_format_name() - Return a string for HDMI connector output format
|
| 1468 | * @fmt: Output format to compute name of
|
| 1469 | *
|
| 1470 | * Returns: the name of the output format, or NULL if the type is not
|
| 1471 | * valid.
|
| 1472 |
|
| 1473 | const char *
|
| 1474 | drm_hdmi_connector_get_output_format_name(enum drm_output_color_format fmt)
|
| 1475 | {
|
| 1476 | if (fmt >= ARRAY_SIZE(output_format_str))
|
| 1477 | return NULL;
|
| 1478 |
|
| 1479 | return output_format_str[fmt];
|
| 1480 | }
|
| 1481 | EXPORT_SYMBOL(drm_hdmi_connector_get_output_format_name);
|
| 1482 |
|
| 1483 | |
| 1484 | * DOC: standard connector properties
|
| 1485 | *
|
| 1486 | * DRM connectors have a few standardized properties:
|
| 1487 | *
|
| 1488 | * EDID:
|
| 1489 | * Blob property which contains the current EDID read from the sink. This
|
| 1490 | * is useful to parse sink identification information like vendor, model
|
| 1491 | * and serial. Drivers should update this property by calling
|
| 1492 | * drm_connector_update_edid_property(), usually after having parsed
|
| 1493 | * the EDID using drm_add_edid_modes(). Userspace cannot change this
|
| 1494 | * property.
|
| 1495 | *
|
| 1496 | * User-space should not parse the EDID to obtain information exposed via
|
| 1497 | * other KMS properties (because the kernel might apply limits, quirks or
|
| 1498 | * fixups to the EDID). For instance, user-space should not try to parse
|
| 1499 | * mode lists from the EDID.
|
| 1500 | * DPMS:
|
| 1501 | * Legacy property for setting the power state of the connector. For atomic
|
| 1502 | * drivers this is only provided for backwards compatibility with existing
|
| 1503 | * drivers, it remaps to controlling the "ACTIVE" property on the CRTC the
|
| 1504 | * connector is linked to. Drivers should never set this property directly,
|
| 1505 | * it is handled by the DRM core by calling the &drm_connector_funcs.dpms
|
| 1506 | * callback. For atomic drivers the remapping to the "ACTIVE" property is
|
| 1507 | * implemented in the DRM core.
|
| 1508 | *
|
| 1509 | * On atomic drivers any DPMS setproperty ioctl where the value does not
|
| 1510 | * change is completely skipped, otherwise a full atomic commit will occur.
|
| 1511 | * On legacy drivers the exact behavior is driver specific.
|
| 1512 | *
|
| 1513 | * Note that this property cannot be set through the MODE_ATOMIC ioctl,
|
| 1514 | * userspace must use "ACTIVE" on the CRTC instead.
|
| 1515 | *
|
| 1516 | * WARNING:
|
| 1517 | *
|
| 1518 | * For userspace also running on legacy drivers the "DPMS" semantics are a
|
| 1519 | * lot more complicated. First, userspace cannot rely on the "DPMS" value
|
| 1520 | * returned by the GETCONNECTOR actually reflecting reality, because many
|
| 1521 | * drivers fail to update it. For atomic drivers this is taken care of in
|
| 1522 | * drm_atomic_helper_update_legacy_modeset_state().
|
| 1523 | *
|
| 1524 | * The second issue is that the DPMS state is only well-defined when the
|
| 1525 | * connector is connected to a CRTC. In atomic the DRM core enforces that
|
| 1526 | * "ACTIVE" is off in such a case, no such checks exists for "DPMS".
|
| 1527 | *
|
| 1528 | * Finally, when enabling an output using the legacy SETCONFIG ioctl then
|
| 1529 | * "DPMS" is forced to ON. But see above, that might not be reflected in
|
| 1530 | * the software value on legacy drivers.
|
| 1531 | *
|
| 1532 | * Summarizing: Only set "DPMS" when the connector is known to be enabled,
|
| 1533 | * assume that a successful SETCONFIG call also sets "DPMS" to on, and
|
| 1534 | * never read back the value of "DPMS" because it can be incorrect.
|
| 1535 | * panel_type:
|
| 1536 | * Immutable enum property to indicate the type of connected panel.
|
| 1537 | * Possible values are "unknown" (default), "OLED", and "LCD".
|
| 1538 | * PATH:
|
| 1539 | * Connector path property to identify how this sink is physically
|
| 1540 | * connected. Used by DP MST. This should be set by calling
|
| 1541 | * drm_connector_set_path_property(), in the case of DP MST with the
|
| 1542 | * path property the MST manager created. Userspace cannot change this
|
| 1543 | * property.
|
| 1544 | *
|
| 1545 | * In the case of DP MST, the property has the format
|
| 1546 | * ``mst:<parent>-<ports>`` where ``<parent>`` is the KMS object ID of the
|
| 1547 | * parent connector and ``<ports>`` is a hyphen-separated list of DP MST
|
| 1548 | * port numbers. Note, KMS object IDs are not guaranteed to be stable
|
| 1549 | * across reboots.
|
| 1550 | * TILE:
|
| 1551 | * Connector tile group property to indicate how a set of DRM connector
|
| 1552 | * compose together into one logical screen. This is used by both high-res
|
| 1553 | * external screens (often only using a single cable, but exposing multiple
|
| 1554 | * DP MST sinks), or high-res integrated panels (like dual-link DSI) which
|
| 1555 | * are not gen-locked. Note that for tiled panels which are genlocked, like
|
| 1556 | * dual-link LVDS or dual-link DSI, the driver should try to not expose the
|
| 1557 | * tiling and virtualise both &drm_crtc and &drm_plane if needed. Drivers
|
| 1558 | * should update this value using drm_connector_set_tile_property().
|
| 1559 | * Userspace cannot change this property.
|
| 1560 | * link-status:
|
| 1561 | * Connector link-status property to indicate the status of link. The
|
| 1562 | * default value of link-status is "GOOD". If something fails during or
|
| 1563 | * after modeset, the kernel driver may set this to "BAD" and issue a
|
| 1564 | * hotplug uevent. Drivers should update this value using
|
| 1565 | * drm_connector_set_link_status_property().
|
| 1566 | *
|
| 1567 | * When user-space receives the hotplug uevent and detects a "BAD"
|
| 1568 | * link-status, the sink doesn't receive pixels anymore (e.g. the screen
|
| 1569 | * becomes completely black). The list of available modes may have
|
| 1570 | * changed. User-space is expected to pick a new mode if the current one
|
| 1571 | * has disappeared and perform a new modeset with link-status set to
|
| 1572 | * "GOOD" to re-enable the connector.
|
| 1573 | *
|
| 1574 | * If multiple connectors share the same CRTC and one of them gets a "BAD"
|
| 1575 | * link-status, the other are unaffected (ie. the sinks still continue to
|
| 1576 | * receive pixels).
|
| 1577 | *
|
| 1578 | * When user-space performs an atomic commit on a connector with a "BAD"
|
| 1579 | * link-status without resetting the property to "GOOD", the sink may
|
| 1580 | * still not receive pixels. When user-space performs an atomic commit
|
| 1581 | * which resets the link-status property to "GOOD" without the
|
| 1582 | * ALLOW_MODESET flag set, it might fail because a modeset is required.
|
| 1583 | *
|
| 1584 | * User-space can only change link-status to "GOOD", changing it to "BAD"
|
| 1585 | * is a no-op.
|
| 1586 | *
|
| 1587 | * For backwards compatibility with non-atomic userspace the kernel
|
| 1588 | * tries to automatically set the link-status back to "GOOD" in the
|
| 1589 | * SETCRTC IOCTL. This might fail if the mode is no longer valid, similar
|
| 1590 | * to how it might fail if a different screen has been connected in the
|
| 1591 | * interim.
|
| 1592 | * non_desktop:
|
| 1593 | * Indicates the output should be ignored for purposes of displaying a
|
| 1594 | * standard desktop environment or console. This is most likely because
|
| 1595 | * the output device is not rectilinear.
|
| 1596 | * Content Protection:
|
| 1597 | * This property is used by userspace to request the kernel protect future
|
| 1598 | * content communicated over the link. When requested, kernel will apply
|
| 1599 | * the appropriate means of protection (most often HDCP), and use the
|
| 1600 | * property to tell userspace the protection is active.
|
| 1601 | *
|
| 1602 | * Drivers can set this up by calling
|
| 1603 | * drm_connector_attach_content_protection_property() on initialization.
|
| 1604 | *
|
| 1605 | * The value of this property can be one of the following:
|
| 1606 | *
|
| 1607 | * DRM_MODE_CONTENT_PROTECTION_UNDESIRED = 0
|
| 1608 | * The link is not protected, content is transmitted in the clear.
|
| 1609 | * DRM_MODE_CONTENT_PROTECTION_DESIRED = 1
|
| 1610 | * Userspace has requested content protection, but the link is not
|
| 1611 | * currently protected. When in this state, kernel should enable
|
| 1612 | * Content Protection as soon as possible.
|
| 1613 | * DRM_MODE_CONTENT_PROTECTION_ENABLED = 2
|
| 1614 | * Userspace has requested content protection, and the link is
|
| 1615 | * protected. Only the driver can set the property to this value.
|
| 1616 | * If userspace attempts to set to ENABLED, kernel will return
|
| 1617 | * -EINVAL.
|
| 1618 | *
|
| 1619 | * A few guidelines:
|
| 1620 | *
|
| 1621 | * - DESIRED state should be preserved until userspace de-asserts it by
|
| 1622 | * setting the property to UNDESIRED. This means ENABLED should only
|
| 1623 | * transition to UNDESIRED when the user explicitly requests it.
|
| 1624 | * - If the state is DESIRED, kernel should attempt to re-authenticate the
|
| 1625 | * link whenever possible. This includes across disable/enable, dpms,
|
| 1626 | * hotplug, downstream device changes, link status failures, etc..
|
| 1627 | * - Kernel sends uevent with the connector id and property id through
|
| 1628 | * @drm_hdcp_update_content_protection, upon below kernel triggered
|
| 1629 | * scenarios:
|
| 1630 | *
|
| 1631 | * - DESIRED -> ENABLED (authentication success)
|
| 1632 | * - ENABLED -> DESIRED (termination of authentication)
|
| 1633 | * - Please note no uevents for userspace triggered property state changes,
|
| 1634 | * which can't fail such as
|
| 1635 | *
|
| 1636 | * - DESIRED/ENABLED -> UNDESIRED
|
| 1637 | * - UNDESIRED -> DESIRED
|
| 1638 | * - Userspace is responsible for polling the property or listen to uevents
|
| 1639 | * to determine when the value transitions from ENABLED to DESIRED.
|
| 1640 | * This signifies the link is no longer protected and userspace should
|
| 1641 | * take appropriate action (whatever that might be).
|
| 1642 | *
|
| 1643 | * HDCP Content Type:
|
| 1644 | * This Enum property is used by the userspace to declare the content type
|
| 1645 | * of the display stream, to kernel. Here display stream stands for any
|
| 1646 | * display content that userspace intended to display through HDCP
|
| 1647 | * encryption.
|
| 1648 | *
|
| 1649 | * Content Type of a stream is decided by the owner of the stream, as
|
| 1650 | * "HDCP Type0" or "HDCP Type1".
|
| 1651 | *
|
| 1652 | * The value of the property can be one of the below:
|
| 1653 | * - "HDCP Type0": DRM_MODE_HDCP_CONTENT_TYPE0 = 0
|
| 1654 | * - "HDCP Type1": DRM_MODE_HDCP_CONTENT_TYPE1 = 1
|
| 1655 | *
|
| 1656 | * When kernel starts the HDCP authentication (see "Content Protection"
|
| 1657 | * for details), it uses the content type in "HDCP Content Type"
|
| 1658 | * for performing the HDCP authentication with the display sink.
|
| 1659 | *
|
| 1660 | * Please note in HDCP spec versions, a link can be authenticated with
|
| 1661 | * HDCP 2.2 for Content Type 0/Content Type 1. Where as a link can be
|
| 1662 | * authenticated with HDCP1.4 only for Content Type 0(though it is implicit
|
| 1663 | * in nature. As there is no reference for Content Type in HDCP1.4).
|
| 1664 | *
|
| 1665 | * HDCP2.2 authentication protocol itself takes the "Content Type" as a
|
| 1666 | * parameter, which is a input for the DP HDCP2.2 encryption algo.
|
| 1667 | *
|
| 1668 | * In case of Type 0 content protection request, kernel driver can choose
|
| 1669 | * either of HDCP spec versions 1.4 and 2.2. When HDCP2.2 is used for
|
| 1670 | * "HDCP Type 0", a HDCP 2.2 capable repeater in the downstream can send
|
| 1671 | * that content to a HDCP 1.4 authenticated HDCP sink (Type0 link).
|
| 1672 | * But if the content is classified as "HDCP Type 1", above mentioned
|
| 1673 | * HDCP 2.2 repeater wont send the content to the HDCP sink as it can't
|
| 1674 | * authenticate the HDCP1.4 capable sink for "HDCP Type 1".
|
| 1675 | *
|
| 1676 | * Please note userspace can be ignorant of the HDCP versions used by the
|
| 1677 | * kernel driver to achieve the "HDCP Content Type".
|
| 1678 | *
|
| 1679 | * At current scenario, classifying a content as Type 1 ensures that the
|
| 1680 | * content will be displayed only through the HDCP2.2 encrypted link.
|
| 1681 | *
|
| 1682 | * Note that the HDCP Content Type property is introduced at HDCP 2.2, and
|
| 1683 | * defaults to type 0. It is only exposed by drivers supporting HDCP 2.2
|
| 1684 | * (hence supporting Type 0 and Type 1). Based on how next versions of
|
| 1685 | * HDCP specs are defined content Type could be used for higher versions
|
| 1686 | * too.
|
| 1687 | *
|
| 1688 | * If content type is changed when "Content Protection" is not UNDESIRED,
|
| 1689 | * then kernel will disable the HDCP and re-enable with new type in the
|
| 1690 | * same atomic commit. And when "Content Protection" is ENABLED, it means
|
| 1691 | * that link is HDCP authenticated and encrypted, for the transmission of
|
| 1692 | * the Type of stream mentioned at "HDCP Content Type".
|
| 1693 | *
|
| 1694 | * HDR_OUTPUT_METADATA:
|
| 1695 | * Connector property to enable userspace to send HDR Metadata to
|
| 1696 | * driver. This metadata is based on the composition and blending
|
| 1697 | * policies decided by user, taking into account the hardware and
|
| 1698 | * sink capabilities. The driver gets this metadata and creates a
|
| 1699 | * Dynamic Range and Mastering Infoframe (DRM) in case of HDMI,
|
| 1700 | * SDP packet (Non-audio INFOFRAME SDP v1.3) for DP. This is then
|
| 1701 | * sent to sink. This notifies the sink of the upcoming frame's Color
|
| 1702 | * Encoding and Luminance parameters.
|
| 1703 | *
|
| 1704 | * Userspace first need to detect the HDR capabilities of sink by
|
| 1705 | * reading and parsing the EDID. Details of HDR metadata for HDMI
|
| 1706 | * are added in CTA 861.G spec. For DP , its defined in VESA DP
|
| 1707 | * Standard v1.4. It needs to then get the metadata information
|
| 1708 | * of the video/game/app content which are encoded in HDR (basically
|
| 1709 | * using HDR transfer functions). With this information it needs to
|
| 1710 | * decide on a blending policy and compose the relevant
|
| 1711 | * layers/overlays into a common format. Once this blending is done,
|
| 1712 | * userspace will be aware of the metadata of the composed frame to
|
| 1713 | * be send to sink. It then uses this property to communicate this
|
| 1714 | * metadata to driver which then make a Infoframe packet and sends
|
| 1715 | * to sink based on the type of encoder connected.
|
| 1716 | *
|
| 1717 | * Userspace will be responsible to do Tone mapping operation in case:
|
| 1718 | * - Some layers are HDR and others are SDR
|
| 1719 | * - HDR layers luminance is not same as sink
|
| 1720 | *
|
| 1721 | * It will even need to do colorspace conversion and get all layers
|
| 1722 | * to one common colorspace for blending. It can use either GL, Media
|
| 1723 | * or display engine to get this done based on the capabilities of the
|
| 1724 | * associated hardware.
|
| 1725 | *
|
| 1726 | * Driver expects metadata to be put in &struct hdr_output_metadata
|
| 1727 | * structure from userspace. This is received as blob and stored in
|
| 1728 | * &drm_connector_state.hdr_output_metadata. It parses EDID and saves the
|
| 1729 | * sink metadata in &struct hdr_sink_metadata, as
|
| 1730 | * &drm_connector.display_info.hdr_sink_metadata. Driver uses
|
| 1731 | * drm_hdmi_infoframe_set_hdr_metadata() helper to set the HDR metadata,
|
| 1732 | * hdmi_drm_infoframe_pack() to pack the infoframe as per spec, in case of
|
| 1733 | * HDMI encoder.
|
| 1734 | *
|
| 1735 | * max bpc:
|
| 1736 | * This range property is used by userspace to limit the bit depth. When
|
| 1737 | * used the driver would limit the bpc in accordance with the valid range
|
| 1738 | * supported by the hardware and sink. Drivers to use the function
|
| 1739 | * drm_connector_attach_max_bpc_property() to create and attach the
|
| 1740 | * property to the connector during initialization.
|
| 1741 | *
|
| 1742 | * Connectors also have one standardized atomic property:
|
| 1743 | *
|
| 1744 | * CRTC_ID:
|
| 1745 | * Mode object ID of the &drm_crtc this connector should be connected to.
|
| 1746 | *
|
| 1747 | * Connectors for LCD panels may also have one standardized property:
|
| 1748 | *
|
| 1749 | * panel orientation:
|
| 1750 | * On some devices the LCD panel is mounted in the casing in such a way
|
| 1751 | * that the up/top side of the panel does not match with the top side of
|
| 1752 | * the device. Userspace can use this property to check for this.
|
| 1753 | * Note that input coordinates from touchscreens (input devices with
|
| 1754 | * INPUT_PROP_DIRECT) will still map 1:1 to the actual LCD panel
|
| 1755 | * coordinates, so if userspace rotates the picture to adjust for
|
| 1756 | * the orientation it must also apply the same transformation to the
|
| 1757 | * touchscreen input coordinates. This property is initialized by calling
|
| 1758 | * drm_connector_set_panel_orientation() or
|
| 1759 | * drm_connector_set_panel_orientation_with_quirk()
|
| 1760 | *
|
| 1761 | * scaling mode:
|
| 1762 | * This property defines how a non-native mode is upscaled to the native
|
| 1763 | * mode of an LCD panel:
|
| 1764 | *
|
| 1765 | * None:
|
| 1766 | * No upscaling happens, scaling is left to the panel. Not all
|
| 1767 | * drivers expose this mode.
|
| 1768 | * Full:
|
| 1769 | * The output is upscaled to the full resolution of the panel,
|
| 1770 | * ignoring the aspect ratio.
|
| 1771 | * Center:
|
| 1772 | * No upscaling happens, the output is centered within the native
|
| 1773 | * resolution the panel.
|
| 1774 | * Full aspect:
|
| 1775 | * The output is upscaled to maximize either the width or height
|
| 1776 | * while retaining the aspect ratio.
|
| 1777 | *
|
| 1778 | * This property should be set up by calling
|
| 1779 | * drm_connector_attach_scaling_mode_property(). Note that drivers
|
| 1780 | * can also expose this property to external outputs, in which case they
|
| 1781 | * must support "None", which should be the default (since external screens
|
| 1782 | * have a built-in scaler).
|
| 1783 | *
|
| 1784 | * subconnector:
|
| 1785 | * This property is used by DVI-I, TVout and DisplayPort to indicate different
|
| 1786 | * connector subtypes. Enum values more or less match with those from main
|
| 1787 | * connector types.
|
| 1788 | * For DVI-I and TVout there is also a matching property "select subconnector"
|
| 1789 | * allowing to switch between signal types.
|
| 1790 | * DP subconnector corresponds to a downstream port.
|
| 1791 | *
|
| 1792 | * privacy-screen sw-state, privacy-screen hw-state:
|
| 1793 | * These 2 optional properties can be used to query the state of the
|
| 1794 | * electronic privacy screen that is available on some displays; and in
|
| 1795 | * some cases also control the state. If a driver implements these
|
| 1796 | * properties then both properties must be present.
|
| 1797 | *
|
| 1798 | * "privacy-screen hw-state" is read-only and reflects the actual state
|
| 1799 | * of the privacy-screen, possible values: "Enabled", "Disabled,
|
| 1800 | * "Enabled-locked", "Disabled-locked". The locked states indicate
|
| 1801 | * that the state cannot be changed through the DRM API. E.g. there
|
| 1802 | * might be devices where the firmware-setup options, or a hardware
|
| 1803 | * slider-switch, offer always on / off modes.
|
| 1804 | *
|
| 1805 | * "privacy-screen sw-state" can be set to change the privacy-screen state
|
| 1806 | * when not locked. In this case the driver must update the hw-state
|
| 1807 | * property to reflect the new state on completion of the commit of the
|
| 1808 | * sw-state property. Setting the sw-state property when the hw-state is
|
| 1809 | * locked must be interpreted by the driver as a request to change the
|
| 1810 | * state to the set state when the hw-state becomes unlocked. E.g. if
|
| 1811 | * "privacy-screen hw-state" is "Enabled-locked" and the sw-state
|
| 1812 | * gets set to "Disabled" followed by the user unlocking the state by
|
| 1813 | * changing the slider-switch position, then the driver must set the
|
| 1814 | * state to "Disabled" upon receiving the unlock event.
|
| 1815 | *
|
| 1816 | * In some cases the privacy-screen's actual state might change outside of
|
| 1817 | * control of the DRM code. E.g. there might be a firmware handled hotkey
|
| 1818 | * which toggles the actual state, or the actual state might be changed
|
| 1819 | * through another userspace API such as writing /proc/acpi/ibm/lcdshadow.
|
| 1820 | * In this case the driver must update both the hw-state and the sw-state
|
| 1821 | * to reflect the new value, overwriting any pending state requests in the
|
| 1822 | * sw-state. Any pending sw-state requests are thus discarded.
|
| 1823 | *
|
| 1824 | * Note that the ability for the state to change outside of control of
|
| 1825 | * the DRM master process means that userspace must not cache the value
|
| 1826 | * of the sw-state. Caching the sw-state value and including it in later
|
| 1827 | * atomic commits may lead to overriding a state change done through e.g.
|
| 1828 | * a firmware handled hotkey. Therefor userspace must not include the
|
| 1829 | * privacy-screen sw-state in an atomic commit unless it wants to change
|
| 1830 | * its value.
|
| 1831 | *
|
| 1832 | * left margin, right margin, top margin, bottom margin:
|
| 1833 | * Add margins to the connector's viewport. This is typically used to
|
| 1834 | * mitigate overscan on TVs.
|
| 1835 | *
|
| 1836 | * The value is the size in pixels of the black border which will be
|
| 1837 | * added. The attached CRTC's content will be scaled to fill the whole
|
| 1838 | * area inside the margin.
|
| 1839 | *
|
| 1840 | * The margins configuration might be sent to the sink, e.g. via HDMI AVI
|
| 1841 | * InfoFrames.
|
| 1842 | *
|
| 1843 | * Drivers can set up these properties by calling
|
| 1844 | * drm_mode_create_tv_margin_properties().
|
| 1845 |
|
| 1846 |
|
| 1847 | int drm_connector_create_standard_properties(struct drm_device *dev)
|
| 1848 | {
|
| 1849 | struct drm_property *prop;
|
| 1850 |
|
| 1851 | prop = drm_property_create(dev, DRM_MODE_PROP_BLOB |
|
| 1852 | DRM_MODE_PROP_IMMUTABLE,
|
| 1853 | "EDID", 0);
|
| 1854 | if (!prop)
|
| 1855 | return -ENOMEM;
|
| 1856 | dev->mode_config.edid_property = prop;
|
| 1857 |
|
| 1858 | prop = drm_property_create_enum(dev, 0,
|
| 1859 | "DPMS", drm_dpms_enum_list,
|
| 1860 | ARRAY_SIZE(drm_dpms_enum_list));
|
| 1861 | if (!prop)
|
| 1862 | return -ENOMEM;
|
| 1863 | dev->mode_config.dpms_property = prop;
|
| 1864 |
|
| 1865 | prop = drm_property_create(dev,
|
| 1866 | DRM_MODE_PROP_BLOB |
|
| 1867 | DRM_MODE_PROP_IMMUTABLE,
|
| 1868 | "PATH", 0);
|
| 1869 | if (!prop)
|
| 1870 | return -ENOMEM;
|
| 1871 | dev->mode_config.path_property = prop;
|
| 1872 |
|
| 1873 | prop = drm_property_create(dev,
|
| 1874 | DRM_MODE_PROP_BLOB |
|
| 1875 | DRM_MODE_PROP_IMMUTABLE,
|
| 1876 | "TILE", 0);
|
| 1877 | if (!prop)
|
| 1878 | return -ENOMEM;
|
| 1879 | dev->mode_config.tile_property = prop;
|
| 1880 |
|
| 1881 | prop = drm_property_create_enum(dev, 0, "link-status",
|
| 1882 | drm_link_status_enum_list,
|
| 1883 | ARRAY_SIZE(drm_link_status_enum_list));
|
| 1884 | if (!prop)
|
| 1885 | return -ENOMEM;
|
| 1886 | dev->mode_config.link_status_property = prop;
|
| 1887 |
|
| 1888 | prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, "panel_type",
|
| 1889 | drm_panel_type_enum_list,
|
| 1890 | ARRAY_SIZE(drm_panel_type_enum_list));
|
| 1891 | if (!prop)
|
| 1892 | return -ENOMEM;
|
| 1893 | dev->mode_config.panel_type_property = prop;
|
| 1894 |
|
| 1895 | prop = drm_property_create_bool(dev, DRM_MODE_PROP_IMMUTABLE, "non-desktop");
|
| 1896 | if (!prop)
|
| 1897 | return -ENOMEM;
|
| 1898 | dev->mode_config.non_desktop_property = prop;
|
| 1899 |
|
| 1900 | prop = drm_property_create(dev, DRM_MODE_PROP_BLOB,
|
| 1901 | "HDR_OUTPUT_METADATA", 0);
|
| 1902 | if (!prop)
|
| 1903 | return -ENOMEM;
|
| 1904 | dev->mode_config.hdr_output_metadata_property = prop;
|
| 1905 |
|
| 1906 | return 0;
|
| 1907 | }
|
| 1908 |
|
| 1909 | |
| 1910 | * drm_mode_create_dvi_i_properties - create DVI-I specific connector properties
|
| 1911 | * @dev: DRM device
|
| 1912 | *
|
| 1913 | * Called by a driver the first time a DVI-I connector is made.
|
| 1914 | *
|
| 1915 | * Returns: %0
|
| 1916 |
|
| 1917 | int drm_mode_create_dvi_i_properties(struct drm_device *dev)
|
| 1918 | {
|
| 1919 | struct drm_property *dvi_i_selector;
|
| 1920 | struct drm_property *dvi_i_subconnector;
|
| 1921 |
|
| 1922 | if (dev->mode_config.dvi_i_select_subconnector_property)
|
| 1923 | return 0;
|
| 1924 |
|
| 1925 | dvi_i_selector =
|
| 1926 | drm_property_create_enum(dev, 0,
|
| 1927 | "select subconnector",
|
| 1928 | drm_dvi_i_select_enum_list,
|
| 1929 | ARRAY_SIZE(drm_dvi_i_select_enum_list));
|
| 1930 | dev->mode_config.dvi_i_select_subconnector_property = dvi_i_selector;
|
| 1931 |
|
| 1932 | dvi_i_subconnector = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
|
| 1933 | "subconnector",
|
| 1934 | drm_dvi_i_subconnector_enum_list,
|
| 1935 | ARRAY_SIZE(drm_dvi_i_subconnector_enum_list));
|
| 1936 | dev->mode_config.dvi_i_subconnector_property = dvi_i_subconnector;
|
| 1937 |
|
| 1938 | return 0;
|
| 1939 | }
|
| 1940 | EXPORT_SYMBOL(drm_mode_create_dvi_i_properties);
|
| 1941 |
|
| 1942 | |
| 1943 | * drm_connector_attach_dp_subconnector_property - create subconnector property for DP
|
| 1944 | * @connector: drm_connector to attach property
|
| 1945 | *
|
| 1946 | * Called by a driver when DP connector is created.
|
| 1947 |
|
| 1948 | void drm_connector_attach_dp_subconnector_property(struct drm_connector *connector)
|
| 1949 | {
|
| 1950 | struct drm_mode_config *mode_config = &connector->dev->mode_config;
|
| 1951 |
|
| 1952 | if (!mode_config->dp_subconnector_property)
|
| 1953 | mode_config->dp_subconnector_property =
|
| 1954 | drm_property_create_enum(connector->dev,
|
| 1955 | DRM_MODE_PROP_IMMUTABLE,
|
| 1956 | "subconnector",
|
| 1957 | drm_dp_subconnector_enum_list,
|
| 1958 | ARRAY_SIZE(drm_dp_subconnector_enum_list));
|
| 1959 |
|
| 1960 | drm_object_attach_property(&connector->base,
|
| 1961 | mode_config->dp_subconnector_property,
|
| 1962 | DRM_MODE_SUBCONNECTOR_Unknown);
|
| 1963 | }
|
| 1964 | EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property);
|
| 1965 |
|
| 1966 | |
| 1967 | * DOC: HDMI connector properties
|
| 1968 | *
|
| 1969 | * Broadcast RGB (HDMI specific)
|
| 1970 | * Indicates the Quantization Range (Full vs Limited) used. The color
|
| 1971 | * processing pipeline will be adjusted to match the value of the
|
| 1972 | * property, and the Infoframes will be generated and sent accordingly.
|
| 1973 | *
|
| 1974 | * This property is only relevant if the HDMI output format is RGB. If
|
| 1975 | * it's one of the YCbCr variant, it will be ignored.
|
| 1976 | *
|
| 1977 | * The CRTC attached to the connector must be configured by user-space to
|
| 1978 | * always produce full-range pixels.
|
| 1979 | *
|
| 1980 | * The value of this property can be one of the following:
|
| 1981 | *
|
| 1982 | * Automatic:
|
| 1983 | * The quantization range is selected automatically based on the
|
| 1984 | * mode according to the HDMI specifications (HDMI 1.4b - Section
|
| 1985 | * 6.6 - Video Quantization Ranges).
|
| 1986 | *
|
| 1987 | * Full:
|
| 1988 | * Full quantization range is forced.
|
| 1989 | *
|
| 1990 | * Limited 16:235:
|
| 1991 | * Limited quantization range is forced. Unlike the name suggests,
|
| 1992 | * this works for any number of bits-per-component.
|
| 1993 | *
|
| 1994 | * Property values other than Automatic can result in colors being off (if
|
| 1995 | * limited is selected but the display expects full), or a black screen
|
| 1996 | * (if full is selected but the display expects limited).
|
| 1997 | *
|
| 1998 | * Drivers can set up this property by calling
|
| 1999 | * drm_connector_attach_broadcast_rgb_property().
|
| 2000 | *
|
| 2001 | * content type (HDMI specific):
|
| 2002 | * Indicates content type setting to be used in HDMI infoframes to indicate
|
| 2003 | * content type for the external device, so that it adjusts its display
|
| 2004 | * settings accordingly.
|
| 2005 | *
|
| 2006 | * The value of this property can be one of the following:
|
| 2007 | *
|
| 2008 | * No Data:
|
| 2009 | * Content type is unknown
|
| 2010 | * Graphics:
|
| 2011 | * Content type is graphics
|
| 2012 | * Photo:
|
| 2013 | * Content type is photo
|
| 2014 | * Cinema:
|
| 2015 | * Content type is cinema
|
| 2016 | * Game:
|
| 2017 | * Content type is game
|
| 2018 | *
|
| 2019 | * The meaning of each content type is defined in CTA-861-G table 15.
|
| 2020 | *
|
| 2021 | * Drivers can set up this property by calling
|
| 2022 | * drm_connector_attach_content_type_property(). Decoding to
|
| 2023 | * infoframe values is done through drm_hdmi_avi_infoframe_content_type().
|
| 2024 |
|
| 2025 |
|
| 2026 | |
| 2027 | * TODO: Document the properties:
|
| 2028 | * - brightness
|
| 2029 | * - contrast
|
| 2030 | * - flicker reduction
|
| 2031 | * - hue
|
| 2032 | * - mode
|
| 2033 | * - overscan
|
| 2034 | * - saturation
|
| 2035 | * - select subconnector
|
| 2036 |
|
| 2037 | |
| 2038 | * DOC: Analog TV Connector Properties
|
| 2039 | *
|
| 2040 | * TV Mode:
|
| 2041 | * Indicates the TV Mode used on an analog TV connector. The value
|
| 2042 | * of this property can be one of the following:
|
| 2043 | *
|
| 2044 | * NTSC:
|
| 2045 | * TV Mode is CCIR System M (aka 525-lines) together with
|
| 2046 | * the NTSC Color Encoding.
|
| 2047 | *
|
| 2048 | * NTSC-443:
|
| 2049 | *
|
| 2050 | * TV Mode is CCIR System M (aka 525-lines) together with
|
| 2051 | * the NTSC Color Encoding, but with a color subcarrier
|
| 2052 | * frequency of 4.43MHz
|
| 2053 | *
|
| 2054 | * NTSC-J:
|
| 2055 | *
|
| 2056 | * TV Mode is CCIR System M (aka 525-lines) together with
|
| 2057 | * the NTSC Color Encoding, but with a black level equal to
|
| 2058 | * the blanking level.
|
| 2059 | *
|
| 2060 | * PAL:
|
| 2061 | *
|
| 2062 | * TV Mode is CCIR System B (aka 625-lines) together with
|
| 2063 | * the PAL Color Encoding.
|
| 2064 | *
|
| 2065 | * PAL-M:
|
| 2066 | *
|
| 2067 | * TV Mode is CCIR System M (aka 525-lines) together with
|
| 2068 | * the PAL Color Encoding.
|
| 2069 | *
|
| 2070 | * PAL-N:
|
| 2071 | *
|
| 2072 | * TV Mode is CCIR System N together with the PAL Color
|
| 2073 | * Encoding, a color subcarrier frequency of 3.58MHz, the
|
| 2074 | * SECAM color space, and narrower channels than other PAL
|
| 2075 | * variants.
|
| 2076 | *
|
| 2077 | * SECAM:
|
| 2078 | *
|
| 2079 | * TV Mode is CCIR System B (aka 625-lines) together with
|
| 2080 | * the SECAM Color Encoding.
|
| 2081 | *
|
| 2082 | * Mono:
|
| 2083 | *
|
| 2084 | * Use timings appropriate to the DRM mode, including
|
| 2085 | * equalizing pulses for a 525-line or 625-line mode,
|
| 2086 | * with no pedestal or color encoding.
|
| 2087 | *
|
| 2088 | * Drivers can set up this property by calling
|
| 2089 | * drm_mode_create_tv_properties().
|
| 2090 |
|
| 2091 |
|
| 2092 | |
| 2093 | * drm_connector_attach_content_type_property - attach content-type property
|
| 2094 | * @connector: connector to attach content type property on.
|
| 2095 | *
|
| 2096 | * Called by a driver the first time a HDMI connector is made.
|
| 2097 | *
|
| 2098 | * Returns: %0
|
| 2099 |
|
| 2100 | int drm_connector_attach_content_type_property(struct drm_connector *connector)
|
| 2101 | {
|
| 2102 | if (!drm_mode_create_content_type_property(connector->dev))
|
| 2103 | drm_object_attach_property(&connector->base,
|
| 2104 | connector->dev->mode_config.content_type_property,
|
| 2105 | DRM_MODE_CONTENT_TYPE_NO_DATA);
|
| 2106 | return 0;
|
| 2107 | }
|
| 2108 | EXPORT_SYMBOL(drm_connector_attach_content_type_property);
|
| 2109 |
|
| 2110 | |
| 2111 | * drm_connector_attach_tv_margin_properties - attach TV connector margin
|
| 2112 | * properties
|
| 2113 | * @connector: DRM connector
|
| 2114 | *
|
| 2115 | * Called by a driver when it needs to attach TV margin props to a connector.
|
| 2116 | * Typically used on SDTV and HDMI connectors.
|
| 2117 |
|
| 2118 | void drm_connector_attach_tv_margin_properties(struct drm_connector *connector)
|
| 2119 | {
|
| 2120 | struct drm_device *dev = connector->dev;
|
| 2121 |
|
| 2122 | drm_object_attach_property(&connector->base,
|
| 2123 | dev->mode_config.tv_left_margin_property,
|
| 2124 | 0);
|
| 2125 | drm_object_attach_property(&connector->base,
|
| 2126 | dev->mode_config.tv_right_margin_property,
|
| 2127 | 0);
|
| 2128 | drm_object_attach_property(&connector->base,
|
| 2129 | dev->mode_config.tv_top_margin_property,
|
| 2130 | 0);
|
| 2131 | drm_object_attach_property(&connector->base,
|
| 2132 | dev->mode_config.tv_bottom_margin_property,
|
| 2133 | 0);
|
| 2134 | }
|
| 2135 | EXPORT_SYMBOL(drm_connector_attach_tv_margin_properties);
|
| 2136 |
|
| 2137 | |
| 2138 | * drm_mode_create_tv_margin_properties - create TV connector margin properties
|
| 2139 | * @dev: DRM device
|
| 2140 | *
|
| 2141 | * Called by a driver's HDMI connector initialization routine, this function
|
| 2142 | * creates the TV margin properties for a given device. No need to call this
|
| 2143 | * function for an SDTV connector, it's already called from
|
| 2144 | * drm_mode_create_tv_properties_legacy().
|
| 2145 | *
|
| 2146 | * Returns:
|
| 2147 | * 0 on success or a negative error code on failure.
|
| 2148 |
|
| 2149 | int drm_mode_create_tv_margin_properties(struct drm_device *dev)
|
| 2150 | {
|
| 2151 | if (dev->mode_config.tv_left_margin_property)
|
| 2152 | return 0;
|
| 2153 |
|
| 2154 | dev->mode_config.tv_left_margin_property =
|
| 2155 | drm_property_create_range(dev, 0, "left margin", 0, 100);
|
| 2156 | if (!dev->mode_config.tv_left_margin_property)
|
| 2157 | return -ENOMEM;
|
| 2158 |
|
| 2159 | dev->mode_config.tv_right_margin_property =
|
| 2160 | drm_property_create_range(dev, 0, "right margin", 0, 100);
|
| 2161 | if (!dev->mode_config.tv_right_margin_property)
|
| 2162 | return -ENOMEM;
|
| 2163 |
|
| 2164 | dev->mode_config.tv_top_margin_property =
|
| 2165 | drm_property_create_range(dev, 0, "top margin", 0, 100);
|
| 2166 | if (!dev->mode_config.tv_top_margin_property)
|
| 2167 | return -ENOMEM;
|
| 2168 |
|
| 2169 | dev->mode_config.tv_bottom_margin_property =
|
| 2170 | drm_property_create_range(dev, 0, "bottom margin", 0, 100);
|
| 2171 | if (!dev->mode_config.tv_bottom_margin_property)
|
| 2172 | return -ENOMEM;
|
| 2173 |
|
| 2174 | return 0;
|
| 2175 | }
|
| 2176 | EXPORT_SYMBOL(drm_mode_create_tv_margin_properties);
|
| 2177 |
|
| 2178 | |
| 2179 | * drm_mode_create_tv_properties_legacy - create TV specific connector properties
|
| 2180 | * @dev: DRM device
|
| 2181 | * @num_modes: number of different TV formats (modes) supported
|
| 2182 | * @modes: array of pointers to strings containing name of each format
|
| 2183 | *
|
| 2184 | * Called by a driver's TV initialization routine, this function creates
|
| 2185 | * the TV specific connector properties for a given device. Caller is
|
| 2186 | * responsible for allocating a list of format names and passing them to
|
| 2187 | * this routine.
|
| 2188 | *
|
| 2189 | * NOTE: This functions registers the deprecated "mode" connector
|
| 2190 | * property to select the analog TV mode (ie, NTSC, PAL, etc.). New
|
| 2191 | * drivers must use drm_mode_create_tv_properties() instead.
|
| 2192 | *
|
| 2193 | * Returns:
|
| 2194 | * 0 on success or a negative error code on failure.
|
| 2195 |
|
| 2196 | int drm_mode_create_tv_properties_legacy(struct drm_device *dev,
|
| 2197 | unsigned int num_modes,
|
| 2198 | const char * const modes[])
|
| 2199 | {
|
| 2200 | struct drm_property *tv_selector;
|
| 2201 | struct drm_property *tv_subconnector;
|
| 2202 | unsigned int i;
|
| 2203 |
|
| 2204 | if (dev->mode_config.tv_select_subconnector_property)
|
| 2205 | return 0;
|
| 2206 |
|
| 2207 | |
| 2208 | * Basic connector properties
|
| 2209 |
|
| 2210 | tv_selector = drm_property_create_enum(dev, 0,
|
| 2211 | "select subconnector",
|
| 2212 | drm_tv_select_enum_list,
|
| 2213 | ARRAY_SIZE(drm_tv_select_enum_list));
|
| 2214 | if (!tv_selector)
|
| 2215 | goto nomem;
|
| 2216 |
|
| 2217 | dev->mode_config.tv_select_subconnector_property = tv_selector;
|
| 2218 |
|
| 2219 | tv_subconnector =
|
| 2220 | drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
|
| 2221 | "subconnector",
|
| 2222 | drm_tv_subconnector_enum_list,
|
| 2223 | ARRAY_SIZE(drm_tv_subconnector_enum_list));
|
| 2224 | if (!tv_subconnector)
|
| 2225 | goto nomem;
|
| 2226 | dev->mode_config.tv_subconnector_property = tv_subconnector;
|
| 2227 |
|
| 2228 | |
| 2229 | * Other, TV specific properties: margins & TV modes.
|
| 2230 |
|
| 2231 | if (drm_mode_create_tv_margin_properties(dev))
|
| 2232 | goto nomem;
|
| 2233 |
|
| 2234 | if (num_modes) {
|
| 2235 | dev->mode_config.legacy_tv_mode_property =
|
| 2236 | drm_property_create(dev, DRM_MODE_PROP_ENUM,
|
| 2237 | "mode", num_modes);
|
| 2238 | if (!dev->mode_config.legacy_tv_mode_property)
|
| 2239 | goto nomem;
|
| 2240 |
|
| 2241 | for (i = 0; i < num_modes; i++)
|
| 2242 | drm_property_add_enum(dev->mode_config.legacy_tv_mode_property,
|
| 2243 | i, modes[i]);
|
| 2244 | }
|
| 2245 |
|
| 2246 | dev->mode_config.tv_brightness_property =
|
| 2247 | drm_property_create_range(dev, 0, "brightness", 0, 100);
|
| 2248 | if (!dev->mode_config.tv_brightness_property)
|
| 2249 | goto nomem;
|
| 2250 |
|
| 2251 | dev->mode_config.tv_contrast_property =
|
| 2252 | drm_property_create_range(dev, 0, "contrast", 0, 100);
|
| 2253 | if (!dev->mode_config.tv_contrast_property)
|
| 2254 | goto nomem;
|
| 2255 |
|
| 2256 | dev->mode_config.tv_flicker_reduction_property =
|
| 2257 | drm_property_create_range(dev, 0, "flicker reduction", 0, 100);
|
| 2258 | if (!dev->mode_config.tv_flicker_reduction_property)
|
| 2259 | goto nomem;
|
| 2260 |
|
| 2261 | dev->mode_config.tv_overscan_property =
|
| 2262 | drm_property_create_range(dev, 0, "overscan", 0, 100);
|
| 2263 | if (!dev->mode_config.tv_overscan_property)
|
| 2264 | goto nomem;
|
| 2265 |
|
| 2266 | dev->mode_config.tv_saturation_property =
|
| 2267 | drm_property_create_range(dev, 0, "saturation", 0, 100);
|
| 2268 | if (!dev->mode_config.tv_saturation_property)
|
| 2269 | goto nomem;
|
| 2270 |
|
| 2271 | dev->mode_config.tv_hue_property =
|
| 2272 | drm_property_create_range(dev, 0, "hue", 0, 100);
|
| 2273 | if (!dev->mode_config.tv_hue_property)
|
| 2274 | goto nomem;
|
| 2275 |
|
| 2276 | return 0;
|
| 2277 | nomem:
|
| 2278 | return -ENOMEM;
|
| 2279 | }
|
| 2280 | EXPORT_SYMBOL(drm_mode_create_tv_properties_legacy);
|
| 2281 |
|
| 2282 | |
| 2283 | * drm_mode_create_tv_properties - create TV specific connector properties
|
| 2284 | * @dev: DRM device
|
| 2285 | * @supported_tv_modes: Bitmask of TV modes supported (See DRM_MODE_TV_MODE_*)
|
| 2286 | *
|
| 2287 | * Called by a driver's TV initialization routine, this function creates
|
| 2288 | * the TV specific connector properties for a given device.
|
| 2289 | *
|
| 2290 | * Returns:
|
| 2291 | * 0 on success or a negative error code on failure.
|
| 2292 |
|
| 2293 | int drm_mode_create_tv_properties(struct drm_device *dev,
|
| 2294 | unsigned int supported_tv_modes)
|
| 2295 | {
|
| 2296 | struct drm_prop_enum_list tv_mode_list[DRM_MODE_TV_MODE_MAX];
|
| 2297 | struct drm_property *tv_mode;
|
| 2298 | unsigned int i, len = 0;
|
| 2299 |
|
| 2300 | if (dev->mode_config.tv_mode_property)
|
| 2301 | return 0;
|
| 2302 |
|
| 2303 | for (i = 0; i < DRM_MODE_TV_MODE_MAX; i++) {
|
| 2304 | if (!(supported_tv_modes & BIT(i)))
|
| 2305 | continue;
|
| 2306 |
|
| 2307 | tv_mode_list[len].type = i;
|
| 2308 | tv_mode_list[len].name = drm_get_tv_mode_name(i);
|
| 2309 | len++;
|
| 2310 | }
|
| 2311 |
|
| 2312 | tv_mode = drm_property_create_enum(dev, 0, "TV mode",
|
| 2313 | tv_mode_list, len);
|
| 2314 | if (!tv_mode)
|
| 2315 | return -ENOMEM;
|
| 2316 |
|
| 2317 | dev->mode_config.tv_mode_property = tv_mode;
|
| 2318 |
|
| 2319 | return drm_mode_create_tv_properties_legacy(dev, 0, NULL);
|
| 2320 | }
|
| 2321 | EXPORT_SYMBOL(drm_mode_create_tv_properties);
|
| 2322 |
|
| 2323 | |
| 2324 | * drm_mode_create_scaling_mode_property - create scaling mode property
|
| 2325 | * @dev: DRM device
|
| 2326 | *
|
| 2327 | * Called by a driver the first time it's needed, must be attached to desired
|
| 2328 | * connectors.
|
| 2329 | *
|
| 2330 | * Atomic drivers should use drm_connector_attach_scaling_mode_property()
|
| 2331 | * instead to correctly assign &drm_connector_state.scaling_mode
|
| 2332 | * in the atomic state.
|
| 2333 | *
|
| 2334 | * Returns: %0
|
| 2335 |
|
| 2336 | int drm_mode_create_scaling_mode_property(struct drm_device *dev)
|
| 2337 | {
|
| 2338 | struct drm_property *scaling_mode;
|
| 2339 |
|
| 2340 | if (dev->mode_config.scaling_mode_property)
|
| 2341 | return 0;
|
| 2342 |
|
| 2343 | scaling_mode =
|
| 2344 | drm_property_create_enum(dev, 0, "scaling mode",
|
| 2345 | drm_scaling_mode_enum_list,
|
| 2346 | ARRAY_SIZE(drm_scaling_mode_enum_list));
|
| 2347 |
|
| 2348 | dev->mode_config.scaling_mode_property = scaling_mode;
|
| 2349 |
|
| 2350 | return 0;
|
| 2351 | }
|
| 2352 | EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
|
| 2353 |
|
| 2354 | |
| 2355 | * DOC: Variable refresh properties
|
| 2356 | *
|
| 2357 | * Variable refresh rate capable displays can dynamically adjust their
|
| 2358 | * refresh rate by extending the duration of their vertical front porch
|
| 2359 | * until page flip or timeout occurs. This can reduce or remove stuttering
|
| 2360 | * and latency in scenarios where the page flip does not align with the
|
| 2361 | * vblank interval.
|
| 2362 | *
|
| 2363 | * An example scenario would be an application flipping at a constant rate
|
| 2364 | * of 48Hz on a 60Hz display. The page flip will frequently miss the vblank
|
| 2365 | * interval and the same contents will be displayed twice. This can be
|
| 2366 | * observed as stuttering for content with motion.
|
| 2367 | *
|
| 2368 | * If variable refresh rate was active on a display that supported a
|
| 2369 | * variable refresh range from 35Hz to 60Hz no stuttering would be observable
|
| 2370 | * for the example scenario. The minimum supported variable refresh rate of
|
| 2371 | * 35Hz is below the page flip frequency and the vertical front porch can
|
| 2372 | * be extended until the page flip occurs. The vblank interval will be
|
| 2373 | * directly aligned to the page flip rate.
|
| 2374 | *
|
| 2375 | * Not all userspace content is suitable for use with variable refresh rate.
|
| 2376 | * Large and frequent changes in vertical front porch duration may worsen
|
| 2377 | * perceived stuttering for input sensitive applications.
|
| 2378 | *
|
| 2379 | * Panel brightness will also vary with vertical front porch duration. Some
|
| 2380 | * panels may have noticeable differences in brightness between the minimum
|
| 2381 | * vertical front porch duration and the maximum vertical front porch duration.
|
| 2382 | * Large and frequent changes in vertical front porch duration may produce
|
| 2383 | * observable flickering for such panels.
|
| 2384 | *
|
| 2385 | * Userspace control for variable refresh rate is supported via properties
|
| 2386 | * on the &drm_connector and &drm_crtc objects.
|
| 2387 | *
|
| 2388 | * "vrr_capable":
|
| 2389 | * Optional &drm_connector boolean property that drivers should attach
|
| 2390 | * with drm_connector_attach_vrr_capable_property() on connectors that
|
| 2391 | * could support variable refresh rates. Drivers should update the
|
| 2392 | * property value by calling drm_connector_set_vrr_capable_property().
|
| 2393 | *
|
| 2394 | * Absence of the property should indicate absence of support.
|
| 2395 | *
|
| 2396 | * "VRR_ENABLED":
|
| 2397 | * Default &drm_crtc boolean property that notifies the driver that the
|
| 2398 | * content on the CRTC is suitable for variable refresh rate presentation.
|
| 2399 | * The driver will take this property as a hint to enable variable
|
| 2400 | * refresh rate support if the receiver supports it, ie. if the
|
| 2401 | * "vrr_capable" property is true on the &drm_connector object. The
|
| 2402 | * vertical front porch duration will be extended until page-flip or
|
| 2403 | * timeout when enabled.
|
| 2404 | *
|
| 2405 | * The minimum vertical front porch duration is defined as the vertical
|
| 2406 | * front porch duration for the current mode.
|
| 2407 | *
|
| 2408 | * The maximum vertical front porch duration is greater than or equal to
|
| 2409 | * the minimum vertical front porch duration. The duration is derived
|
| 2410 | * from the minimum supported variable refresh rate for the connector.
|
| 2411 | *
|
| 2412 | * The driver may place further restrictions within these minimum
|
| 2413 | * and maximum bounds.
|
| 2414 |
|
| 2415 |
|
| 2416 | |
| 2417 | * drm_connector_attach_vrr_capable_property - creates the
|
| 2418 | * vrr_capable property
|
| 2419 | * @connector: connector to create the vrr_capable property on.
|
| 2420 | *
|
| 2421 | * This is used by atomic drivers to add support for querying
|
| 2422 | * variable refresh rate capability for a connector.
|
| 2423 | *
|
| 2424 | * Returns:
|
| 2425 | * Zero on success, negative errno on failure.
|
| 2426 |
|
| 2427 | int drm_connector_attach_vrr_capable_property(
|
| 2428 | struct drm_connector *connector)
|
| 2429 | {
|
| 2430 | struct drm_device *dev = connector->dev;
|
| 2431 | struct drm_property *prop;
|
| 2432 |
|
| 2433 | if (!connector->vrr_capable_property) {
|
| 2434 | prop = drm_property_create_bool(dev, DRM_MODE_PROP_IMMUTABLE,
|
| 2435 | "vrr_capable");
|
| 2436 | if (!prop)
|
| 2437 | return -ENOMEM;
|
| 2438 |
|
| 2439 | connector->vrr_capable_property = prop;
|
| 2440 | drm_object_attach_property(&connector->base, prop, 0);
|
| 2441 | }
|
| 2442 |
|
| 2443 | return 0;
|
| 2444 | }
|
| 2445 | EXPORT_SYMBOL(drm_connector_attach_vrr_capable_property);
|
| 2446 |
|
| 2447 | |
| 2448 | * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
|
| 2449 | * @connector: connector to attach scaling mode property on.
|
| 2450 | * @scaling_mode_mask: or'ed mask of BIT(%DRM_MODE_SCALE_\*).
|
| 2451 | *
|
| 2452 | * This is used to add support for scaling mode to atomic drivers.
|
| 2453 | * The scaling mode will be set to &drm_connector_state.scaling_mode
|
| 2454 | * and can be used from &drm_connector_helper_funcs->atomic_check for validation.
|
| 2455 | *
|
| 2456 | * This is the atomic version of drm_mode_create_scaling_mode_property().
|
| 2457 | *
|
| 2458 | * Returns:
|
| 2459 | * Zero on success, negative errno on failure.
|
| 2460 |
|
| 2461 | int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
|
| 2462 | u32 scaling_mode_mask)
|
| 2463 | {
|
| 2464 | struct drm_device *dev = connector->dev;
|
| 2465 | struct drm_property *scaling_mode_property;
|
| 2466 | int i;
|
| 2467 | const unsigned valid_scaling_mode_mask =
|
| 2468 | (1U << ARRAY_SIZE(drm_scaling_mode_enum_list)) - 1;
|
| 2469 |
|
| 2470 | if (WARN_ON(hweight32(scaling_mode_mask) < 2 ||
|
| 2471 | scaling_mode_mask & ~valid_scaling_mode_mask))
|
| 2472 | return -EINVAL;
|
| 2473 |
|
| 2474 | scaling_mode_property =
|
| 2475 | drm_property_create(dev, DRM_MODE_PROP_ENUM, "scaling mode",
|
| 2476 | hweight32(scaling_mode_mask));
|
| 2477 |
|
| 2478 | if (!scaling_mode_property)
|
| 2479 | return -ENOMEM;
|
| 2480 |
|
| 2481 | for (i = 0; i < ARRAY_SIZE(drm_scaling_mode_enum_list); i++) {
|
| 2482 | int ret;
|
| 2483 |
|
| 2484 | if (!(BIT(i) & scaling_mode_mask))
|
| 2485 | continue;
|
| 2486 |
|
| 2487 | ret = drm_property_add_enum(scaling_mode_property,
|
| 2488 | drm_scaling_mode_enum_list[i].type,
|
| 2489 | drm_scaling_mode_enum_list[i].name);
|
| 2490 |
|
| 2491 | if (ret) {
|
| 2492 | drm_property_destroy(dev, scaling_mode_property);
|
| 2493 |
|
| 2494 | return ret;
|
| 2495 | }
|
| 2496 | }
|
| 2497 |
|
| 2498 | drm_object_attach_property(&connector->base,
|
| 2499 | scaling_mode_property, 0);
|
| 2500 |
|
| 2501 | connector->scaling_mode_property = scaling_mode_property;
|
| 2502 |
|
| 2503 | return 0;
|
| 2504 | }
|
| 2505 | EXPORT_SYMBOL(drm_connector_attach_scaling_mode_property);
|
| 2506 |
|
| 2507 | |
| 2508 | * drm_mode_create_aspect_ratio_property - create aspect ratio property
|
| 2509 | * @dev: DRM device
|
| 2510 | *
|
| 2511 | * Called by a driver the first time it's needed, must be attached to desired
|
| 2512 | * connectors.
|
| 2513 | *
|
| 2514 | * Returns:
|
| 2515 | * Zero on success, negative errno on failure.
|
| 2516 |
|
| 2517 | int drm_mode_create_aspect_ratio_property(struct drm_device *dev)
|
| 2518 | {
|
| 2519 | if (dev->mode_config.aspect_ratio_property)
|
| 2520 | return 0;
|
| 2521 |
|
| 2522 | dev->mode_config.aspect_ratio_property =
|
| 2523 | drm_property_create_enum(dev, 0, "aspect ratio",
|
| 2524 | drm_aspect_ratio_enum_list,
|
| 2525 | ARRAY_SIZE(drm_aspect_ratio_enum_list));
|
| 2526 |
|
| 2527 | if (dev->mode_config.aspect_ratio_property == NULL)
|
| 2528 | return -ENOMEM;
|
| 2529 |
|
| 2530 | return 0;
|
| 2531 | }
|
| 2532 | EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
|
| 2533 |
|
| 2534 | |
| 2535 | * DOC: standard connector properties
|
| 2536 | *
|
| 2537 | * Colorspace:
|
| 2538 | * This property is used to inform the driver about the color encoding
|
| 2539 | * user space configured the pixel operation properties to produce.
|
| 2540 | * The variants set the colorimetry, transfer characteristics, and which
|
| 2541 | * YCbCr conversion should be used when necessary.
|
| 2542 | * The transfer characteristics from HDR_OUTPUT_METADATA takes precedence
|
| 2543 | * over this property.
|
| 2544 | * User space always configures the pixel operation properties to produce
|
| 2545 | * full quantization range data (see the Broadcast RGB property).
|
| 2546 | *
|
| 2547 | * Drivers inform the sink about what colorimetry, transfer
|
| 2548 | * characteristics, YCbCr conversion, and quantization range to expect
|
| 2549 | * (this can depend on the output mode, output format and other
|
| 2550 | * properties). Drivers also convert the user space provided data to what
|
| 2551 | * the sink expects.
|
| 2552 | *
|
| 2553 | * User space has to check if the sink supports all of the possible
|
| 2554 | * colorimetries that the driver is allowed to pick by parsing the EDID.
|
| 2555 | *
|
| 2556 | * For historical reasons this property exposes a number of variants which
|
| 2557 | * result in undefined behavior.
|
| 2558 | *
|
| 2559 | * Default:
|
| 2560 | * The behavior is driver-specific.
|
| 2561 | *
|
| 2562 | * BT2020_RGB:
|
| 2563 | *
|
| 2564 | * BT2020_YCC:
|
| 2565 | * User space configures the pixel operation properties to produce
|
| 2566 | * RGB content with Rec. ITU-R BT.2020 colorimetry, Rec.
|
| 2567 | * ITU-R BT.2020 (Table 4, RGB) transfer characteristics and full
|
| 2568 | * quantization range.
|
| 2569 | * User space can use the HDR_OUTPUT_METADATA property to set the
|
| 2570 | * transfer characteristics to PQ (Rec. ITU-R BT.2100 Table 4) or
|
| 2571 | * HLG (Rec. ITU-R BT.2100 Table 5) in which case, user space
|
| 2572 | * configures pixel operation properties to produce content with
|
| 2573 | * the respective transfer characteristics.
|
| 2574 | * User space has to make sure the sink supports Rec.
|
| 2575 | * ITU-R BT.2020 R'G'B' and Rec. ITU-R BT.2020 Y'C'BC'R
|
| 2576 | * colorimetry.
|
| 2577 | * Drivers can configure the sink to use an RGB format, tell the
|
| 2578 | * sink to expect Rec. ITU-R BT.2020 R'G'B' colorimetry and convert
|
| 2579 | * to the appropriate quantization range.
|
| 2580 | * Drivers can configure the sink to use a YCbCr format, tell the
|
| 2581 | * sink to expect Rec. ITU-R BT.2020 Y'C'BC'R colorimetry, convert
|
| 2582 | * to YCbCr using the Rec. ITU-R BT.2020 non-constant luminance
|
| 2583 | * conversion matrix and convert to the appropriate quantization
|
| 2584 | * range.
|
| 2585 | * The variants BT2020_RGB and BT2020_YCC are equivalent and the
|
| 2586 | * driver chooses between RGB and YCbCr based on the color format
|
| 2587 | * property.
|
| 2588 | *
|
| 2589 | * SMPTE_170M_YCC:
|
| 2590 | * BT709_YCC:
|
| 2591 | * XVYCC_601:
|
| 2592 | * XVYCC_709:
|
| 2593 | * SYCC_601:
|
| 2594 | * opYCC_601:
|
| 2595 | * opRGB:
|
| 2596 | * BT2020_CYCC:
|
| 2597 | * DCI-P3_RGB_D65:
|
| 2598 | * DCI-P3_RGB_Theater:
|
| 2599 | * RGB_WIDE_FIXED:
|
| 2600 | * RGB_WIDE_FLOAT:
|
| 2601 | *
|
| 2602 | * BT601_YCC:
|
| 2603 | * The behavior is undefined.
|
| 2604 | *
|
| 2605 | * Because between HDMI and DP have different colorspaces,
|
| 2606 | * drm_mode_create_hdmi_colorspace_property() is used for HDMI connector and
|
| 2607 | * drm_mode_create_dp_colorspace_property() is used for DP connector.
|
| 2608 |
|
| 2609 |
|
| 2610 | static int drm_mode_create_colorspace_property(struct drm_connector *connector,
|
| 2611 | u32 supported_colorspaces)
|
| 2612 | {
|
| 2613 | struct drm_device *dev = connector->dev;
|
| 2614 | u32 colorspaces = supported_colorspaces | BIT(DRM_MODE_COLORIMETRY_DEFAULT);
|
| 2615 | struct drm_prop_enum_list enum_list[DRM_MODE_COLORIMETRY_COUNT];
|
| 2616 | int i, len;
|
| 2617 |
|
| 2618 | if (connector->colorspace_property)
|
| 2619 | return 0;
|
| 2620 |
|
| 2621 | if (!supported_colorspaces) {
|
| 2622 | drm_err(dev, "No supported colorspaces provded on [CONNECTOR:%d:%s]\n",
|
| 2623 | connector->base.id, connector->name);
|
| 2624 | return -EINVAL;
|
| 2625 | }
|
| 2626 |
|
| 2627 | if ((supported_colorspaces & -BIT(DRM_MODE_COLORIMETRY_COUNT)) != 0) {
|
| 2628 | drm_err(dev, "Unknown colorspace provded on [CONNECTOR:%d:%s]\n",
|
| 2629 | connector->base.id, connector->name);
|
| 2630 | return -EINVAL;
|
| 2631 | }
|
| 2632 |
|
| 2633 | len = 0;
|
| 2634 | for (i = 0; i < DRM_MODE_COLORIMETRY_COUNT; i++) {
|
| 2635 | if ((colorspaces & BIT(i)) == 0)
|
| 2636 | continue;
|
| 2637 |
|
| 2638 | enum_list[len].type = i;
|
| 2639 | enum_list[len].name = colorspace_names[i];
|
| 2640 | len++;
|
| 2641 | }
|
| 2642 |
|
| 2643 | connector->colorspace_property =
|
| 2644 | drm_property_create_enum(dev, DRM_MODE_PROP_ENUM, "Colorspace",
|
| 2645 | enum_list,
|
| 2646 | len);
|
| 2647 |
|
| 2648 | if (!connector->colorspace_property)
|
| 2649 | return -ENOMEM;
|
| 2650 |
|
| 2651 | return 0;
|
| 2652 | }
|
| 2653 |
|
| 2654 | |
| 2655 | * drm_mode_create_hdmi_colorspace_property - create hdmi colorspace property
|
| 2656 | * @connector: connector to create the Colorspace property on.
|
| 2657 | * @supported_colorspaces: bitmap of supported color spaces
|
| 2658 | *
|
| 2659 | * Called by a driver the first time it's needed, must be attached to desired
|
| 2660 | * HDMI connectors.
|
| 2661 | *
|
| 2662 | * Returns:
|
| 2663 | * Zero on success, negative errno on failure.
|
| 2664 |
|
| 2665 | int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector,
|
| 2666 | u32 supported_colorspaces)
|
| 2667 | {
|
| 2668 | u32 colorspaces;
|
| 2669 |
|
| 2670 | if (supported_colorspaces)
|
| 2671 | colorspaces = supported_colorspaces & hdmi_colorspaces;
|
| 2672 | else
|
| 2673 | colorspaces = hdmi_colorspaces;
|
| 2674 |
|
| 2675 | return drm_mode_create_colorspace_property(connector, colorspaces);
|
| 2676 | }
|
| 2677 | EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property);
|
| 2678 |
|
| 2679 | |
| 2680 | * drm_mode_create_dp_colorspace_property - create dp colorspace property
|
| 2681 | * @connector: connector to create the Colorspace property on.
|
| 2682 | * @supported_colorspaces: bitmap of supported color spaces
|
| 2683 | *
|
| 2684 | * Called by a driver the first time it's needed, must be attached to desired
|
| 2685 | * DP connectors.
|
| 2686 | *
|
| 2687 | * Returns:
|
| 2688 | * Zero on success, negative errno on failure.
|
| 2689 |
|
| 2690 | int drm_mode_create_dp_colorspace_property(struct drm_connector *connector,
|
| 2691 | u32 supported_colorspaces)
|
| 2692 | {
|
| 2693 | u32 colorspaces;
|
| 2694 |
|
| 2695 | if (supported_colorspaces)
|
| 2696 | colorspaces = supported_colorspaces & dp_colorspaces;
|
| 2697 | else
|
| 2698 | colorspaces = dp_colorspaces;
|
| 2699 |
|
| 2700 | return drm_mode_create_colorspace_property(connector, colorspaces);
|
| 2701 | }
|
| 2702 | EXPORT_SYMBOL(drm_mode_create_dp_colorspace_property);
|
| 2703 |
|
| 2704 | |
| 2705 | * drm_mode_create_content_type_property - create content type property
|
| 2706 | * @dev: DRM device
|
| 2707 | *
|
| 2708 | * Called by a driver the first time it's needed, must be attached to desired
|
| 2709 | * connectors.
|
| 2710 | *
|
| 2711 | * Returns:
|
| 2712 | * Zero on success, negative errno on failure.
|
| 2713 |
|
| 2714 | int drm_mode_create_content_type_property(struct drm_device *dev)
|
| 2715 | {
|
| 2716 | if (dev->mode_config.content_type_property)
|
| 2717 | return 0;
|
| 2718 |
|
| 2719 | dev->mode_config.content_type_property =
|
| 2720 | drm_property_create_enum(dev, 0, "content type",
|
| 2721 | drm_content_type_enum_list,
|
| 2722 | ARRAY_SIZE(drm_content_type_enum_list));
|
| 2723 |
|
| 2724 | if (dev->mode_config.content_type_property == NULL)
|
| 2725 | return -ENOMEM;
|
| 2726 |
|
| 2727 | return 0;
|
| 2728 | }
|
| 2729 | EXPORT_SYMBOL(drm_mode_create_content_type_property);
|
| 2730 |
|
| 2731 | |
| 2732 | * drm_mode_create_suggested_offset_properties - create suggests offset properties
|
| 2733 | * @dev: DRM device
|
| 2734 | *
|
| 2735 | * Create the suggested x/y offset property for connectors.
|
| 2736 | *
|
| 2737 | * Returns:
|
| 2738 | * 0 on success or a negative error code on failure.
|
| 2739 |
|
| 2740 | int drm_mode_create_suggested_offset_properties(struct drm_device *dev)
|
| 2741 | {
|
| 2742 | if (dev->mode_config.suggested_x_property && dev->mode_config.suggested_y_property)
|
| 2743 | return 0;
|
| 2744 |
|
| 2745 | dev->mode_config.suggested_x_property =
|
| 2746 | drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, "suggested X", 0, 0xffffffff);
|
| 2747 |
|
| 2748 | dev->mode_config.suggested_y_property =
|
| 2749 | drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, "suggested Y", 0, 0xffffffff);
|
| 2750 |
|
| 2751 | if (dev->mode_config.suggested_x_property == NULL ||
|
| 2752 | dev->mode_config.suggested_y_property == NULL)
|
| 2753 | return -ENOMEM;
|
| 2754 | return 0;
|
| 2755 | }
|
| 2756 | EXPORT_SYMBOL(drm_mode_create_suggested_offset_properties);
|
| 2757 |
|
| 2758 | |
| 2759 | * drm_connector_set_path_property - set tile property on connector
|
| 2760 | * @connector: connector to set property on.
|
| 2761 | * @path: path to use for property; must not be NULL.
|
| 2762 | *
|
| 2763 | * This creates a property to expose to userspace to specify a
|
| 2764 | * connector path. This is mainly used for DisplayPort MST where
|
| 2765 | * connectors have a topology and we want to allow userspace to give
|
| 2766 | * them more meaningful names.
|
| 2767 | *
|
| 2768 | * Returns:
|
| 2769 | * Zero on success, negative errno on failure.
|
| 2770 |
|
| 2771 | int drm_connector_set_path_property(struct drm_connector *connector,
|
| 2772 | const char *path)
|
| 2773 | {
|
| 2774 | struct drm_device *dev = connector->dev;
|
| 2775 | int ret;
|
| 2776 |
|
| 2777 | ret = drm_property_replace_global_blob(dev,
|
| 2778 | &connector->path_blob_ptr,
|
| 2779 | strlen(path) + 1,
|
| 2780 | path,
|
| 2781 | &connector->base,
|
| 2782 | dev->mode_config.path_property);
|
| 2783 | return ret;
|
| 2784 | }
|
| 2785 | EXPORT_SYMBOL(drm_connector_set_path_property);
|
| 2786 |
|
| 2787 | |
| 2788 | * drm_connector_set_tile_property - set tile property on connector
|
| 2789 | * @connector: connector to set property on.
|
| 2790 | *
|
| 2791 | * This looks up the tile information for a connector, and creates a
|
| 2792 | * property for userspace to parse if it exists. The property is of
|
| 2793 | * the form of 8 integers using ':' as a separator.
|
| 2794 | * This is used for dual port tiled displays with DisplayPort SST
|
| 2795 | * or DisplayPort MST connectors.
|
| 2796 | *
|
| 2797 | * Returns:
|
| 2798 | * Zero on success, errno on failure.
|
| 2799 |
|
| 2800 | int drm_connector_set_tile_property(struct drm_connector *connector)
|
| 2801 | {
|
| 2802 | struct drm_device *dev = connector->dev;
|
| 2803 | char tile[256];
|
| 2804 | int ret;
|
| 2805 |
|
| 2806 | if (!connector->has_tile) {
|
| 2807 | ret = drm_property_replace_global_blob(dev,
|
| 2808 | &connector->tile_blob_ptr,
|
| 2809 | 0,
|
| 2810 | NULL,
|
| 2811 | &connector->base,
|
| 2812 | dev->mode_config.tile_property);
|
| 2813 | return ret;
|
| 2814 | }
|
| 2815 |
|
| 2816 | snprintf(tile, 256, "%d:%d:%d:%d:%d:%d:%d:%d",
|
| 2817 | connector->tile_group->id, connector->tile_is_single_monitor,
|
| 2818 | connector->num_h_tile, connector->num_v_tile,
|
| 2819 | connector->tile_h_loc, connector->tile_v_loc,
|
| 2820 | connector->tile_h_size, connector->tile_v_size);
|
| 2821 |
|
| 2822 | ret = drm_property_replace_global_blob(dev,
|
| 2823 | &connector->tile_blob_ptr,
|
| 2824 | strlen(tile) + 1,
|
| 2825 | tile,
|
| 2826 | &connector->base,
|
| 2827 | dev->mode_config.tile_property);
|
| 2828 | return ret;
|
| 2829 | }
|
| 2830 | EXPORT_SYMBOL(drm_connector_set_tile_property);
|
| 2831 |
|
| 2832 | |
| 2833 | * drm_connector_set_link_status_property - Set link status property of a connector
|
| 2834 | * @connector: drm connector
|
| 2835 | * @link_status: new value of link status property (0: Good, 1: Bad)
|
| 2836 | *
|
| 2837 | * In usual working scenario, this link status property will always be set to
|
| 2838 | * "GOOD". If something fails during or after a mode set, the kernel driver
|
| 2839 | * may set this link status property to "BAD". The caller then needs to send a
|
| 2840 | * hotplug uevent for userspace to re-check the valid modes through
|
| 2841 | * GET_CONNECTOR_IOCTL and retry modeset.
|
| 2842 | *
|
| 2843 | * Note: Drivers cannot rely on userspace to support this property and
|
| 2844 | * issue a modeset. As such, they may choose to handle issues (like
|
| 2845 | * re-training a link) without userspace's intervention.
|
| 2846 | *
|
| 2847 | * The reason for adding this property is to handle link training failures, but
|
| 2848 | * it is not limited to DP or link training. For example, if we implement
|
| 2849 | * asynchronous setcrtc, this property can be used to report any failures in that.
|
| 2850 |
|
| 2851 | void drm_connector_set_link_status_property(struct drm_connector *connector,
|
| 2852 | uint64_t link_status)
|
| 2853 | {
|
| 2854 | struct drm_device *dev = connector->dev;
|
| 2855 |
|
| 2856 | drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
|
| 2857 | connector->state->link_status = link_status;
|
| 2858 | drm_modeset_unlock(&dev->mode_config.connection_mutex);
|
| 2859 | }
|
| 2860 | EXPORT_SYMBOL(drm_connector_set_link_status_property);
|
| 2861 |
|
| 2862 | |
| 2863 | * drm_connector_attach_max_bpc_property - attach "max bpc" property
|
| 2864 | * @connector: connector to attach max bpc property on.
|
| 2865 | * @min: The minimum bit depth supported by the connector.
|
| 2866 | * @max: The maximum bit depth supported by the connector.
|
| 2867 | *
|
| 2868 | * This is used to add support for limiting the bit depth on a connector.
|
| 2869 | *
|
| 2870 | * Returns:
|
| 2871 | * Zero on success, negative errno on failure.
|
| 2872 |
|
| 2873 | int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
|
| 2874 | int min, int max)
|
| 2875 | {
|
| 2876 | struct drm_device *dev = connector->dev;
|
| 2877 | struct drm_property *prop;
|
| 2878 |
|
| 2879 | prop = connector->max_bpc_property;
|
| 2880 | if (!prop) {
|
| 2881 | prop = drm_property_create_range(dev, 0, "max bpc", min, max);
|
| 2882 | if (!prop)
|
| 2883 | return -ENOMEM;
|
| 2884 |
|
| 2885 | connector->max_bpc_property = prop;
|
| 2886 | }
|
| 2887 |
|
| 2888 | drm_object_attach_property(&connector->base, prop, max);
|
| 2889 | connector->state->max_requested_bpc = max;
|
| 2890 | connector->state->max_bpc = max;
|
| 2891 |
|
| 2892 | return 0;
|
| 2893 | }
|
| 2894 | EXPORT_SYMBOL(drm_connector_attach_max_bpc_property);
|
| 2895 |
|
| 2896 | |
| 2897 | * drm_connector_attach_hdr_output_metadata_property - attach "HDR_OUTPUT_METADATA" property
|
| 2898 | * @connector: connector to attach the property on.
|
| 2899 | *
|
| 2900 | * This is used to allow the userspace to send HDR Metadata to the
|
| 2901 | * driver.
|
| 2902 |
|
| 2903 | void drm_connector_attach_hdr_output_metadata_property(struct drm_connector *connector)
|
| 2904 | {
|
| 2905 | struct drm_device *dev = connector->dev;
|
| 2906 | struct drm_property *prop = dev->mode_config.hdr_output_metadata_property;
|
| 2907 |
|
| 2908 | drm_object_attach_property(&connector->base, prop, 0);
|
| 2909 | }
|
| 2910 | EXPORT_SYMBOL(drm_connector_attach_hdr_output_metadata_property);
|
| 2911 |
|
| 2912 | |
| 2913 | * drm_connector_attach_broadcast_rgb_property - attach "Broadcast RGB" property
|
| 2914 | * @connector: connector to attach the property on.
|
| 2915 | *
|
| 2916 | * This is used to add support for forcing the RGB range on a connector
|
| 2917 | *
|
| 2918 | * Returns:
|
| 2919 | * Zero on success, negative errno on failure.
|
| 2920 |
|
| 2921 | int drm_connector_attach_broadcast_rgb_property(struct drm_connector *connector)
|
| 2922 | {
|
| 2923 | struct drm_device *dev = connector->dev;
|
| 2924 | struct drm_property *prop;
|
| 2925 |
|
| 2926 | prop = connector->broadcast_rgb_property;
|
| 2927 | if (!prop) {
|
| 2928 | prop = drm_property_create_enum(dev, DRM_MODE_PROP_ENUM,
|
| 2929 | "Broadcast RGB",
|
| 2930 | broadcast_rgb_names,
|
| 2931 | ARRAY_SIZE(broadcast_rgb_names));
|
| 2932 | if (!prop)
|
| 2933 | return -EINVAL;
|
| 2934 |
|
| 2935 | connector->broadcast_rgb_property = prop;
|
| 2936 | }
|
| 2937 |
|
| 2938 | drm_object_attach_property(&connector->base, prop,
|
| 2939 | DRM_HDMI_BROADCAST_RGB_AUTO);
|
| 2940 |
|
| 2941 | return 0;
|
| 2942 | }
|
| 2943 | EXPORT_SYMBOL(drm_connector_attach_broadcast_rgb_property);
|
| 2944 |
|
| 2945 | |
| 2946 | * drm_connector_attach_colorspace_property - attach "Colorspace" property
|
| 2947 | * @connector: connector to attach the property on.
|
| 2948 | *
|
| 2949 | * This is used to allow the userspace to signal the output colorspace
|
| 2950 | * to the driver.
|
| 2951 | *
|
| 2952 | * Returns:
|
| 2953 | * Zero on success, negative errno on failure.
|
| 2954 |
|
| 2955 | int drm_connector_attach_colorspace_property(struct drm_connector *connector)
|
| 2956 | {
|
| 2957 | struct drm_property *prop = connector->colorspace_property;
|
| 2958 |
|
| 2959 | drm_object_attach_property(&connector->base, prop, DRM_MODE_COLORIMETRY_DEFAULT);
|
| 2960 |
|
| 2961 | return 0;
|
| 2962 | }
|
| 2963 | EXPORT_SYMBOL(drm_connector_attach_colorspace_property);
|
| 2964 |
|
| 2965 | |
| 2966 | * DOC: Color format
|
| 2967 | *
|
| 2968 | * The connector "color format" property allows userspace to request a specific
|
| 2969 | * color model on the output of the connector. Not all values listed by the
|
| 2970 | * property are guaranteed to work for every sink; rather, it is an optimistic
|
| 2971 | * listing of color formats that the source could output depending on
|
| 2972 | * circumstances.
|
| 2973 | *
|
| 2974 | * Whether it actually can output a certain color format is determined during
|
| 2975 | * the atomic check phase. Consequently, a userspace application that sets the
|
| 2976 | * color format to a value other than "AUTO" should check whether its atomic
|
| 2977 | * commit succeeded.
|
| 2978 | *
|
| 2979 | * Possible values for "color format":
|
| 2980 | *
|
| 2981 | * "AUTO":
|
| 2982 | * The driver or display protocol helpers should pick a suitable color
|
| 2983 | * format. All implementations of a specific display protocol will behave
|
| 2984 | * the same way with "AUTO", but different display protocols do not
|
| 2985 | * necessarily have the same "AUTO" semantics.
|
| 2986 | *
|
| 2987 | * For HDMI connectors, "AUTO" picks RGB, but falls back to YUV 4:2:0 if
|
| 2988 | * the bandwidth required for full-scale RGB is not available, or the mode
|
| 2989 | * is YUV 4:2:0-only, as long as the mode, source, and sink all support
|
| 2990 | * YUV 4:2:0.
|
| 2991 | * "RGB":
|
| 2992 | * RGB output format. The quantization range (limited/full) depends on the
|
| 2993 | * value of the "Broadcast RGB" property if it is present on the connector.
|
| 2994 | * "YUV 4:4:4":
|
| 2995 | * YUV 4:4:4 (a.k.a. YCbCr 4:4:4) output format. Chroma is not subsampled.
|
| 2996 | * The quantization range defaults to limited.
|
| 2997 | * "YUV 4:2:2":
|
| 2998 | * YUV 4:2:2 (a.k.a. YCbCr 4:2:2) output format. Chroma has half the
|
| 2999 | * horizontal resolution of Luma. The quantization range defaults to
|
| 3000 | * limited.
|
| 3001 | * "YUV 4:2:0":
|
| 3002 | * YUV 4:2:0 (a.k.a. YCbCr 4:2:0) output format. Chroma has half the
|
| 3003 | * horizontal and vertical resolution of Luma. The quantization range
|
| 3004 | * defaults to limited.
|
| 3005 | *
|
| 3006 | * A sink may only support some color formats in specific modes and at specific
|
| 3007 | * bit depths. The atomic modesetting API should be used to set a working
|
| 3008 | * configuration in one go, as an unsupported combination of parameters is
|
| 3009 | * rejected.
|
| 3010 |
|
| 3011 |
|
| 3012 | |
| 3013 | * drm_connector_attach_color_format_property - create and attach color format property
|
| 3014 | * @connector: connector to create the color format property on
|
| 3015 | * @supported_color_formats: bitmask of bit-shifted &enum drm_output_color_format
|
| 3016 | * values the connector supports
|
| 3017 | *
|
| 3018 | * Called by a driver to create a color format property. The property is
|
| 3019 | * attached to the connector automatically on success.
|
| 3020 | *
|
| 3021 | * @supported_color_formats should only include color formats the connector
|
| 3022 | * type can actually support.
|
| 3023 | *
|
| 3024 | * Returns:
|
| 3025 | * 0 on success, negative errno on error
|
| 3026 |
|
| 3027 | int drm_connector_attach_color_format_property(struct drm_connector *connector,
|
| 3028 | unsigned long supported_color_formats)
|
| 3029 | {
|
| 3030 | struct drm_device *dev = connector->dev;
|
| 3031 | struct drm_prop_enum_list enum_list[DRM_CONNECTOR_COLOR_FORMAT_COUNT];
|
| 3032 | unsigned int i = 0;
|
| 3033 | unsigned long fmt;
|
| 3034 |
|
| 3035 | if (connector->color_format_property)
|
| 3036 | return 0;
|
| 3037 |
|
| 3038 | if (!supported_color_formats) {
|
| 3039 | drm_err(dev, "No supported color formats provided on [CONNECTOR:%d:%s]\n",
|
| 3040 | connector->base.id, connector->name);
|
| 3041 | return -EINVAL;
|
| 3042 | }
|
| 3043 |
|
| 3044 | if (supported_color_formats & ~GENMASK(DRM_OUTPUT_COLOR_FORMAT_COUNT - 1, 0)) {
|
| 3045 | drm_err(dev, "Unknown color formats provided on [CONNECTOR:%d:%s]\n",
|
| 3046 | connector->base.id, connector->name);
|
| 3047 | return -EINVAL;
|
| 3048 | }
|
| 3049 |
|
| 3050 | switch (connector->connector_type) {
|
| 3051 | case DRM_MODE_CONNECTOR_HDMIA:
|
| 3052 | case DRM_MODE_CONNECTOR_HDMIB:
|
| 3053 | if (supported_color_formats & ~hdmi_colorformats) {
|
| 3054 | drm_err(dev, "Color formats not allowed for HDMI on [CONNECTOR:%d:%s]\n",
|
| 3055 | connector->base.id, connector->name);
|
| 3056 | return -EINVAL;
|
| 3057 | }
|
| 3058 | break;
|
| 3059 | case DRM_MODE_CONNECTOR_DisplayPort:
|
| 3060 | case DRM_MODE_CONNECTOR_eDP:
|
| 3061 | if (supported_color_formats & ~dp_colorformats) {
|
| 3062 | drm_err(dev, "Color formats not allowed for DP on [CONNECTOR:%d:%s]\n",
|
| 3063 | connector->base.id, connector->name);
|
| 3064 | return -EINVAL;
|
| 3065 | }
|
| 3066 | break;
|
| 3067 | }
|
| 3068 |
|
| 3069 | enum_list[0].name = "AUTO";
|
| 3070 | enum_list[0].type = DRM_CONNECTOR_COLOR_FORMAT_AUTO;
|
| 3071 |
|
| 3072 | for_each_set_bit(fmt, &supported_color_formats, DRM_OUTPUT_COLOR_FORMAT_COUNT) {
|
| 3073 | switch (fmt) {
|
| 3074 | case DRM_OUTPUT_COLOR_FORMAT_RGB444:
|
| 3075 | enum_list[++i].type = DRM_CONNECTOR_COLOR_FORMAT_RGB444;
|
| 3076 | break;
|
| 3077 | case DRM_OUTPUT_COLOR_FORMAT_YCBCR444:
|
| 3078 | enum_list[++i].type = DRM_CONNECTOR_COLOR_FORMAT_YCBCR444;
|
| 3079 | break;
|
| 3080 | case DRM_OUTPUT_COLOR_FORMAT_YCBCR422:
|
| 3081 | enum_list[++i].type = DRM_CONNECTOR_COLOR_FORMAT_YCBCR422;
|
| 3082 | break;
|
| 3083 | case DRM_OUTPUT_COLOR_FORMAT_YCBCR420:
|
| 3084 | enum_list[++i].type = DRM_CONNECTOR_COLOR_FORMAT_YCBCR420;
|
| 3085 | break;
|
| 3086 | default:
|
| 3087 | drm_warn(dev, "Unknown supported format %ld on [CONNECTOR:%d:%s]\n",
|
| 3088 | fmt, connector->base.id, connector->name);
|
| 3089 | continue;
|
| 3090 | }
|
| 3091 | enum_list[i].name = drm_hdmi_connector_get_output_format_name(fmt);
|
| 3092 | }
|
| 3093 |
|
| 3094 | connector->color_format_property =
|
| 3095 | drm_property_create_enum(dev, DRM_MODE_PROP_ENUM, "color format",
|
| 3096 | enum_list, i + 1);
|
| 3097 |
|
| 3098 | if (!connector->color_format_property)
|
| 3099 | return -ENOMEM;
|
| 3100 |
|
| 3101 | drm_object_attach_property(&connector->base, connector->color_format_property,
|
| 3102 | DRM_CONNECTOR_COLOR_FORMAT_AUTO);
|
| 3103 |
|
| 3104 | return 0;
|
| 3105 | }
|
| 3106 | EXPORT_SYMBOL(drm_connector_attach_color_format_property);
|
| 3107 |
|
| 3108 | |
| 3109 | * drm_connector_atomic_hdr_metadata_equal - checks if the hdr metadata changed
|
| 3110 | * @old_state: old connector state to compare
|
| 3111 | * @new_state: new connector state to compare
|
| 3112 | *
|
| 3113 | * This is used by HDR-enabled drivers to test whether the HDR metadata
|
| 3114 | * have changed between two different connector state (and thus probably
|
| 3115 | * requires a full blown mode change).
|
| 3116 | *
|
| 3117 | * Returns:
|
| 3118 | * True if the metadata are equal, False otherwise
|
| 3119 |
|
| 3120 | bool drm_connector_atomic_hdr_metadata_equal(struct drm_connector_state *old_state,
|
| 3121 | struct drm_connector_state *new_state)
|
| 3122 | {
|
| 3123 | struct drm_property_blob *old_blob = old_state->hdr_output_metadata;
|
| 3124 | struct drm_property_blob *new_blob = new_state->hdr_output_metadata;
|
| 3125 |
|
| 3126 | if (!old_blob || !new_blob)
|
| 3127 | return old_blob == new_blob;
|
| 3128 |
|
| 3129 | if (old_blob->length != new_blob->length)
|
| 3130 | return false;
|
| 3131 |
|
| 3132 | return !memcmp(old_blob->data, new_blob->data, old_blob->length);
|
| 3133 | }
|
| 3134 | EXPORT_SYMBOL(drm_connector_atomic_hdr_metadata_equal);
|
| 3135 |
|
| 3136 | |
| 3137 | * drm_connector_set_vrr_capable_property - sets the variable refresh rate
|
| 3138 | * capable property for a connector
|
| 3139 | * @connector: drm connector
|
| 3140 | * @capable: True if the connector is variable refresh rate capable
|
| 3141 | *
|
| 3142 | * Should be used by atomic drivers to update the indicated support for
|
| 3143 | * variable refresh rate over a connector.
|
| 3144 |
|
| 3145 | void drm_connector_set_vrr_capable_property(
|
| 3146 | struct drm_connector *connector, bool capable)
|
| 3147 | {
|
| 3148 | if (!connector->vrr_capable_property)
|
| 3149 | return;
|
| 3150 |
|
| 3151 | drm_object_property_set_value(&connector->base,
|
| 3152 | connector->vrr_capable_property,
|
| 3153 | capable);
|
| 3154 | }
|
| 3155 | EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
|
| 3156 |
|
| 3157 | |
| 3158 | * drm_connector_set_panel_orientation - sets the connector's panel_orientation
|
| 3159 | * @connector: connector for which to set the panel-orientation property.
|
| 3160 | * @panel_orientation: drm_panel_orientation value to set
|
| 3161 | *
|
| 3162 | * This function sets the connector's panel_orientation and attaches
|
| 3163 | * a "panel orientation" property to the connector.
|
| 3164 | *
|
| 3165 | * Calling this function on a connector where the panel_orientation has
|
| 3166 | * already been set is a no-op (e.g. the orientation has been overridden with
|
| 3167 | * a kernel commandline option).
|
| 3168 | *
|
| 3169 | * It is allowed to call this function with a panel_orientation of
|
| 3170 | * DRM_MODE_PANEL_ORIENTATION_UNKNOWN, in which case it is a no-op.
|
| 3171 | *
|
| 3172 | * The function shouldn't be called in panel after drm is registered (i.e.
|
| 3173 | * drm_dev_register() is called in drm).
|
| 3174 | *
|
| 3175 | * Returns:
|
| 3176 | * Zero on success, negative errno on failure.
|
| 3177 |
|
| 3178 | int drm_connector_set_panel_orientation(
|
| 3179 | struct drm_connector *connector,
|
| 3180 | enum drm_panel_orientation panel_orientation)
|
| 3181 | {
|
| 3182 | struct drm_device *dev = connector->dev;
|
| 3183 | struct drm_display_info *info = &connector->display_info;
|
| 3184 | struct drm_property *prop;
|
| 3185 |
|
| 3186 |
|
| 3187 | if (info->panel_orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
|
| 3188 | return 0;
|
| 3189 |
|
| 3190 |
|
| 3191 | if (panel_orientation == DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
|
| 3192 | return 0;
|
| 3193 |
|
| 3194 | info->panel_orientation = panel_orientation;
|
| 3195 |
|
| 3196 | prop = dev->mode_config.panel_orientation_property;
|
| 3197 | if (!prop) {
|
| 3198 | prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
|
| 3199 | "panel orientation",
|
| 3200 | drm_panel_orientation_enum_list,
|
| 3201 | ARRAY_SIZE(drm_panel_orientation_enum_list));
|
| 3202 | if (!prop)
|
| 3203 | return -ENOMEM;
|
| 3204 |
|
| 3205 | dev->mode_config.panel_orientation_property = prop;
|
| 3206 | }
|
| 3207 |
|
| 3208 | drm_object_attach_property(&connector->base, prop,
|
| 3209 | info->panel_orientation);
|
| 3210 | return 0;
|
| 3211 | }
|
| 3212 | EXPORT_SYMBOL(drm_connector_set_panel_orientation);
|
| 3213 |
|
| 3214 | |
| 3215 | * drm_connector_set_panel_orientation_with_quirk - set the
|
| 3216 | * connector's panel_orientation after checking for quirks
|
| 3217 | * @connector: connector for which to init the panel-orientation property.
|
| 3218 | * @panel_orientation: drm_panel_orientation value to set
|
| 3219 | * @width: width in pixels of the panel, used for panel quirk detection
|
| 3220 | * @height: height in pixels of the panel, used for panel quirk detection
|
| 3221 | *
|
| 3222 | * Like drm_connector_set_panel_orientation(), but with a check for platform
|
| 3223 | * specific (e.g. DMI based) quirks overriding the passed in panel_orientation.
|
| 3224 | *
|
| 3225 | * Returns:
|
| 3226 | * Zero on success, negative errno on failure.
|
| 3227 |
|
| 3228 | int drm_connector_set_panel_orientation_with_quirk(
|
| 3229 | struct drm_connector *connector,
|
| 3230 | enum drm_panel_orientation panel_orientation,
|
| 3231 | int width, int height)
|
| 3232 | {
|
| 3233 | int orientation_quirk;
|
| 3234 |
|
| 3235 | orientation_quirk = drm_get_panel_orientation_quirk(width, height);
|
| 3236 | if (orientation_quirk != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
|
| 3237 | panel_orientation = orientation_quirk;
|
| 3238 |
|
| 3239 | return drm_connector_set_panel_orientation(connector,
|
| 3240 | panel_orientation);
|
| 3241 | }
|
| 3242 | EXPORT_SYMBOL(drm_connector_set_panel_orientation_with_quirk);
|
| 3243 |
|
| 3244 | |
| 3245 | * drm_connector_set_orientation_from_panel -
|
| 3246 | * set the connector's panel_orientation from panel's callback.
|
| 3247 | * @connector: connector for which to init the panel-orientation property.
|
| 3248 | * @panel: panel that can provide orientation information.
|
| 3249 | *
|
| 3250 | * Drm drivers should call this function before drm_dev_register().
|
| 3251 | * Orientation is obtained from panel's .get_orientation() callback.
|
| 3252 | *
|
| 3253 | * Returns:
|
| 3254 | * Zero on success, negative errno on failure.
|
| 3255 |
|
| 3256 | int drm_connector_set_orientation_from_panel(
|
| 3257 | struct drm_connector *connector,
|
| 3258 | struct drm_panel *panel)
|
| 3259 | {
|
| 3260 | enum drm_panel_orientation orientation;
|
| 3261 |
|
| 3262 | if (panel && panel->funcs && panel->funcs->get_orientation)
|
| 3263 | orientation = panel->funcs->get_orientation(panel);
|
| 3264 | else
|
| 3265 | orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
|
| 3266 |
|
| 3267 | return drm_connector_set_panel_orientation(connector, orientation);
|
| 3268 | }
|
| 3269 | EXPORT_SYMBOL(drm_connector_set_orientation_from_panel);
|
| 3270 |
|
| 3271 | static const struct drm_prop_enum_list privacy_screen_enum[] = {
|
| 3272 | { PRIVACY_SCREEN_DISABLED, "Disabled" },
|
| 3273 | { PRIVACY_SCREEN_ENABLED, "Enabled" },
|
| 3274 | { PRIVACY_SCREEN_DISABLED_LOCKED, "Disabled-locked" },
|
| 3275 | { PRIVACY_SCREEN_ENABLED_LOCKED, "Enabled-locked" },
|
| 3276 | };
|
| 3277 |
|
| 3278 | |
| 3279 | * drm_connector_create_privacy_screen_properties - create the drm connecter's
|
| 3280 | * privacy-screen properties.
|
| 3281 | * @connector: connector for which to create the privacy-screen properties
|
| 3282 | *
|
| 3283 | * This function creates the "privacy-screen sw-state" and "privacy-screen
|
| 3284 | * hw-state" properties for the connector. They are not attached.
|
| 3285 |
|
| 3286 | void
|
| 3287 | drm_connector_create_privacy_screen_properties(struct drm_connector *connector)
|
| 3288 | {
|
| 3289 | if (connector->privacy_screen_sw_state_property)
|
| 3290 | return;
|
| 3291 |
|
| 3292 |
|
| 3293 | connector->privacy_screen_sw_state_property =
|
| 3294 | drm_property_create_enum(connector->dev, DRM_MODE_PROP_ENUM,
|
| 3295 | "privacy-screen sw-state",
|
| 3296 | privacy_screen_enum, 2);
|
| 3297 |
|
| 3298 | connector->privacy_screen_hw_state_property =
|
| 3299 | drm_property_create_enum(connector->dev,
|
| 3300 | DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ENUM,
|
| 3301 | "privacy-screen hw-state",
|
| 3302 | privacy_screen_enum,
|
| 3303 | ARRAY_SIZE(privacy_screen_enum));
|
| 3304 | }
|
| 3305 | EXPORT_SYMBOL(drm_connector_create_privacy_screen_properties);
|
| 3306 |
|
| 3307 | |
| 3308 | * drm_connector_attach_privacy_screen_properties - attach the drm connecter's
|
| 3309 | * privacy-screen properties.
|
| 3310 | * @connector: connector on which to attach the privacy-screen properties
|
| 3311 | *
|
| 3312 | * This function attaches the "privacy-screen sw-state" and "privacy-screen
|
| 3313 | * hw-state" properties to the connector. The initial state of both is set
|
| 3314 | * to "Disabled".
|
| 3315 |
|
| 3316 | void
|
| 3317 | drm_connector_attach_privacy_screen_properties(struct drm_connector *connector)
|
| 3318 | {
|
| 3319 | if (!connector->privacy_screen_sw_state_property)
|
| 3320 | return;
|
| 3321 |
|
| 3322 | drm_object_attach_property(&connector->base,
|
| 3323 | connector->privacy_screen_sw_state_property,
|
| 3324 | PRIVACY_SCREEN_DISABLED);
|
| 3325 |
|
| 3326 | drm_object_attach_property(&connector->base,
|
| 3327 | connector->privacy_screen_hw_state_property,
|
| 3328 | PRIVACY_SCREEN_DISABLED);
|
| 3329 | }
|
| 3330 | EXPORT_SYMBOL(drm_connector_attach_privacy_screen_properties);
|
| 3331 |
|
| 3332 | static void drm_connector_update_privacy_screen_properties(
|
| 3333 | struct drm_connector *connector, bool set_sw_state)
|
| 3334 | {
|
| 3335 | enum drm_privacy_screen_status sw_state, hw_state;
|
| 3336 |
|
| 3337 | drm_privacy_screen_get_state(connector->privacy_screen,
|
| 3338 | &sw_state, &hw_state);
|
| 3339 |
|
| 3340 | if (set_sw_state)
|
| 3341 | connector->state->privacy_screen_sw_state = sw_state;
|
| 3342 | drm_object_property_set_value(&connector->base,
|
| 3343 | connector->privacy_screen_hw_state_property, hw_state);
|
| 3344 | }
|
| 3345 |
|
| 3346 | static int drm_connector_privacy_screen_notifier(
|
| 3347 | struct notifier_block *nb, unsigned long action, void *data)
|
| 3348 | {
|
| 3349 | struct drm_connector *connector =
|
| 3350 | container_of(nb, struct drm_connector, privacy_screen_notifier);
|
| 3351 | struct drm_device *dev = connector->dev;
|
| 3352 |
|
| 3353 | drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
|
| 3354 | drm_connector_update_privacy_screen_properties(connector, true);
|
| 3355 | drm_modeset_unlock(&dev->mode_config.connection_mutex);
|
| 3356 |
|
| 3357 | drm_sysfs_connector_property_event(connector,
|
| 3358 | connector->privacy_screen_sw_state_property);
|
| 3359 | drm_sysfs_connector_property_event(connector,
|
| 3360 | connector->privacy_screen_hw_state_property);
|
| 3361 |
|
| 3362 | return NOTIFY_DONE;
|
| 3363 | }
|
| 3364 |
|
| 3365 | |
| 3366 | * drm_connector_attach_privacy_screen_provider - attach a privacy-screen to
|
| 3367 | * the connector
|
| 3368 | * @connector: connector to attach the privacy-screen to
|
| 3369 | * @priv: drm_privacy_screen to attach
|
| 3370 | *
|
| 3371 | * Create and attach the standard privacy-screen properties and register
|
| 3372 | * a generic notifier for generating sysfs-connector-status-events
|
| 3373 | * on external changes to the privacy-screen status.
|
| 3374 | * This function takes ownership of the passed in drm_privacy_screen and will
|
| 3375 | * call drm_privacy_screen_put() on it when the connector is destroyed.
|
| 3376 |
|
| 3377 | void drm_connector_attach_privacy_screen_provider(
|
| 3378 | struct drm_connector *connector, struct drm_privacy_screen *priv)
|
| 3379 | {
|
| 3380 | connector->privacy_screen = priv;
|
| 3381 | connector->privacy_screen_notifier.notifier_call =
|
| 3382 | drm_connector_privacy_screen_notifier;
|
| 3383 |
|
| 3384 | drm_connector_create_privacy_screen_properties(connector);
|
| 3385 | drm_connector_update_privacy_screen_properties(connector, true);
|
| 3386 | drm_connector_attach_privacy_screen_properties(connector);
|
| 3387 | }
|
| 3388 | EXPORT_SYMBOL(drm_connector_attach_privacy_screen_provider);
|
| 3389 |
|
| 3390 | |
| 3391 | * drm_connector_update_privacy_screen - update connector's privacy-screen sw-state
|
| 3392 | * @connector_state: connector-state to update the privacy-screen for
|
| 3393 | *
|
| 3394 | * This function calls drm_privacy_screen_set_sw_state() on the connector's
|
| 3395 | * privacy-screen.
|
| 3396 | *
|
| 3397 | * If the connector has no privacy-screen, then this is a no-op.
|
| 3398 |
|
| 3399 | void drm_connector_update_privacy_screen(const struct drm_connector_state *connector_state)
|
| 3400 | {
|
| 3401 | struct drm_connector *connector = connector_state->connector;
|
| 3402 | int ret;
|
| 3403 |
|
| 3404 | if (!connector->privacy_screen)
|
| 3405 | return;
|
| 3406 |
|
| 3407 | ret = drm_privacy_screen_set_sw_state(connector->privacy_screen,
|
| 3408 | connector_state->privacy_screen_sw_state);
|
| 3409 | if (ret) {
|
| 3410 | drm_err(connector->dev, "Error updating privacy-screen sw_state\n");
|
| 3411 | return;
|
| 3412 | }
|
| 3413 |
|
| 3414 |
|
| 3415 | drm_connector_update_privacy_screen_properties(connector, false);
|
| 3416 | }
|
| 3417 | EXPORT_SYMBOL(drm_connector_update_privacy_screen);
|
| 3418 |
|
| 3419 | int drm_connector_set_obj_prop(struct drm_mode_object *obj,
|
| 3420 | struct drm_property *property,
|
| 3421 | uint64_t value)
|
| 3422 | {
|
| 3423 | int ret = -EINVAL;
|
| 3424 | struct drm_connector *connector = obj_to_connector(obj);
|
| 3425 |
|
| 3426 |
|
| 3427 | if (property == connector->dev->mode_config.dpms_property) {
|
| 3428 | ret = (*connector->funcs->dpms)(connector, (int)value);
|
| 3429 | } else if (connector->funcs->set_property)
|
| 3430 | ret = connector->funcs->set_property(connector, property, value);
|
| 3431 |
|
| 3432 | if (!ret)
|
| 3433 | drm_object_property_set_value(&connector->base, property, value);
|
| 3434 | return ret;
|
| 3435 | }
|
| 3436 |
|
| 3437 | int drm_connector_property_set_ioctl(struct drm_device *dev,
|
| 3438 | void *data, struct drm_file *file_priv)
|
| 3439 | {
|
| 3440 | struct drm_mode_connector_set_property *conn_set_prop = data;
|
| 3441 | struct drm_mode_obj_set_property obj_set_prop = {
|
| 3442 | .value = conn_set_prop->value,
|
| 3443 | .prop_id = conn_set_prop->prop_id,
|
| 3444 | .obj_id = conn_set_prop->connector_id,
|
| 3445 | .obj_type = DRM_MODE_OBJECT_CONNECTOR
|
| 3446 | };
|
| 3447 |
|
| 3448 |
|
| 3449 | return drm_mode_obj_set_property_ioctl(dev, &obj_set_prop, file_priv);
|
| 3450 | }
|
| 3451 |
|
| 3452 | static struct drm_encoder *drm_connector_get_encoder(struct drm_connector *connector)
|
| 3453 | {
|
| 3454 | |
| 3455 | * protected by modeset locks, so check those first.
|
| 3456 |
|
| 3457 | if (connector->state)
|
| 3458 | return connector->state->best_encoder;
|
| 3459 | return connector->encoder;
|
| 3460 | }
|
| 3461 |
|
| 3462 | static bool
|
| 3463 | drm_mode_expose_to_userspace(const struct drm_display_mode *mode,
|
| 3464 | const struct list_head *modes,
|
| 3465 | const struct drm_file *file_priv)
|
| 3466 | {
|
| 3467 | |
| 3468 | * If user-space hasn't configured the driver to expose the stereo 3D
|
| 3469 | * modes, don't expose them.
|
| 3470 |
|
| 3471 | if (!file_priv->stereo_allowed && drm_mode_is_stereo(mode))
|
| 3472 | return false;
|
| 3473 | |
| 3474 | * If user-space hasn't configured the driver to expose the modes
|
| 3475 | * with aspect-ratio, don't expose them. However if such a mode
|
| 3476 | * is unique, let it be exposed, but reset the aspect-ratio flags
|
| 3477 | * while preparing the list of user-modes.
|
| 3478 |
|
| 3479 | if (!file_priv->aspect_ratio_allowed) {
|
| 3480 | const struct drm_display_mode *mode_itr;
|
| 3481 |
|
| 3482 | list_for_each_entry(mode_itr, modes, head) {
|
| 3483 | if (mode_itr->expose_to_userspace &&
|
| 3484 | drm_mode_match(mode_itr, mode,
|
| 3485 | DRM_MODE_MATCH_TIMINGS |
|
| 3486 | DRM_MODE_MATCH_CLOCK |
|
| 3487 | DRM_MODE_MATCH_FLAGS |
|
| 3488 | DRM_MODE_MATCH_3D_FLAGS))
|
| 3489 | return false;
|
| 3490 | }
|
| 3491 | }
|
| 3492 |
|
| 3493 | return true;
|
| 3494 | }
|
| 3495 |
|
| 3496 | int drm_mode_getconnector(struct drm_device *dev, void *data,
|
| 3497 | struct drm_file *file_priv)
|
| 3498 | {
|
| 3499 | struct drm_mode_get_connector *out_resp = data;
|
| 3500 | struct drm_connector *connector;
|
| 3501 | struct drm_encoder *encoder;
|
| 3502 | struct drm_display_mode *mode;
|
| 3503 | int mode_count = 0;
|
| 3504 | int encoders_count = 0;
|
| 3505 | int ret = 0;
|
| 3506 | int copied = 0;
|
| 3507 | struct drm_mode_modeinfo u_mode;
|
| 3508 | struct drm_mode_modeinfo __user *mode_ptr;
|
| 3509 | uint32_t __user *encoder_ptr;
|
| 3510 | bool is_current_master;
|
| 3511 |
|
| 3512 | if (!drm_core_check_feature(dev, DRIVER_MODESET))
|
| 3513 | return -EOPNOTSUPP;
|
| 3514 |
|
| 3515 | memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));
|
| 3516 |
|
| 3517 | connector = drm_connector_lookup(dev, file_priv, out_resp->connector_id);
|
| 3518 | if (!connector)
|
| 3519 | return -ENOENT;
|
| 3520 |
|
| 3521 | encoders_count = hweight32(connector->possible_encoders);
|
| 3522 |
|
| 3523 | if ((out_resp->count_encoders >= encoders_count) && encoders_count) {
|
| 3524 | copied = 0;
|
| 3525 | encoder_ptr = (uint32_t __user *)(unsigned long)(out_resp->encoders_ptr);
|
| 3526 |
|
| 3527 | drm_connector_for_each_possible_encoder(connector, encoder) {
|
| 3528 | if (put_user(encoder->base.id, encoder_ptr + copied)) {
|
| 3529 | ret = -EFAULT;
|
| 3530 | goto out;
|
| 3531 | }
|
| 3532 | copied++;
|
| 3533 | }
|
| 3534 | }
|
| 3535 | out_resp->count_encoders = encoders_count;
|
| 3536 |
|
| 3537 | out_resp->connector_id = connector->base.id;
|
| 3538 | out_resp->connector_type = connector->connector_type;
|
| 3539 | out_resp->connector_type_id = connector->connector_type_id;
|
| 3540 |
|
| 3541 | is_current_master = drm_is_current_master(file_priv);
|
| 3542 |
|
| 3543 | mutex_lock(&dev->mode_config.mutex);
|
| 3544 | if (out_resp->count_modes == 0) {
|
| 3545 | if (is_current_master)
|
| 3546 | connector->funcs->fill_modes(connector,
|
| 3547 | dev->mode_config.max_width,
|
| 3548 | dev->mode_config.max_height);
|
| 3549 | else
|
| 3550 | drm_dbg_kms(dev, "User-space requested a forced probe on [CONNECTOR:%d:%s] but is not the DRM master, demoting to read-only probe\n",
|
| 3551 | connector->base.id, connector->name);
|
| 3552 | }
|
| 3553 |
|
| 3554 | out_resp->mm_width = connector->display_info.width_mm;
|
| 3555 | out_resp->mm_height = connector->display_info.height_mm;
|
| 3556 | out_resp->subpixel = connector->display_info.subpixel_order;
|
| 3557 | out_resp->connection = connector->status;
|
| 3558 |
|
| 3559 |
|
| 3560 | list_for_each_entry(mode, &connector->modes, head) {
|
| 3561 | WARN_ON(mode->expose_to_userspace);
|
| 3562 |
|
| 3563 | if (drm_mode_expose_to_userspace(mode, &connector->modes,
|
| 3564 | file_priv)) {
|
| 3565 | mode->expose_to_userspace = true;
|
| 3566 | mode_count++;
|
| 3567 | }
|
| 3568 | }
|
| 3569 |
|
| 3570 | |
| 3571 | * This ioctl is called twice, once to determine how much space is
|
| 3572 | * needed, and the 2nd time to fill it.
|
| 3573 |
|
| 3574 | if ((out_resp->count_modes >= mode_count) && mode_count) {
|
| 3575 | copied = 0;
|
| 3576 | mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long)out_resp->modes_ptr;
|
| 3577 | list_for_each_entry(mode, &connector->modes, head) {
|
| 3578 | if (!mode->expose_to_userspace)
|
| 3579 | continue;
|
| 3580 |
|
| 3581 |
|
| 3582 | mode->expose_to_userspace = false;
|
| 3583 |
|
| 3584 | drm_mode_convert_to_umode(&u_mode, mode);
|
| 3585 | |
| 3586 | * Reset aspect ratio flags of user-mode, if modes with
|
| 3587 | * aspect-ratio are not supported.
|
| 3588 |
|
| 3589 | if (!file_priv->aspect_ratio_allowed)
|
| 3590 | u_mode.flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
|
| 3591 | if (copy_to_user(mode_ptr + copied,
|
| 3592 | &u_mode, sizeof(u_mode))) {
|
| 3593 | ret = -EFAULT;
|
| 3594 |
|
| 3595 | |
| 3596 | * Clear the tag for the rest of
|
| 3597 | * the modes for the next time around.
|
| 3598 |
|
| 3599 | list_for_each_entry_continue(mode, &connector->modes, head)
|
| 3600 | mode->expose_to_userspace = false;
|
| 3601 |
|
| 3602 | mutex_unlock(&dev->mode_config.mutex);
|
| 3603 |
|
| 3604 | goto out;
|
| 3605 | }
|
| 3606 | copied++;
|
| 3607 | }
|
| 3608 | } else {
|
| 3609 |
|
| 3610 | list_for_each_entry(mode, &connector->modes, head)
|
| 3611 | mode->expose_to_userspace = false;
|
| 3612 | }
|
| 3613 |
|
| 3614 | out_resp->count_modes = mode_count;
|
| 3615 | mutex_unlock(&dev->mode_config.mutex);
|
| 3616 |
|
| 3617 | drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
|
| 3618 | encoder = drm_connector_get_encoder(connector);
|
| 3619 | if (encoder)
|
| 3620 | out_resp->encoder_id = encoder->base.id;
|
| 3621 | else
|
| 3622 | out_resp->encoder_id = 0;
|
| 3623 |
|
| 3624 | |
| 3625 | * properties reflect the latest status.
|
| 3626 |
|
| 3627 | ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
|
| 3628 | file_priv->plane_color_pipeline,
|
| 3629 | (uint32_t __user *)(unsigned long)(out_resp->props_ptr),
|
| 3630 | (uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
|
| 3631 | &out_resp->count_props);
|
| 3632 | drm_modeset_unlock(&dev->mode_config.connection_mutex);
|
| 3633 |
|
| 3634 | out:
|
| 3635 | drm_connector_put(connector);
|
| 3636 |
|
| 3637 | return ret;
|
| 3638 | }
|
| 3639 |
|
| 3640 | |
| 3641 | * drm_connector_find_by_fwnode - Find a connector based on the associated fwnode
|
| 3642 | * @fwnode: fwnode for which to find the matching drm_connector
|
| 3643 | *
|
| 3644 | * This functions looks up a drm_connector based on its associated fwnode. When
|
| 3645 | * a connector is found a reference to the connector is returned. The caller must
|
| 3646 | * call drm_connector_put() to release this reference when it is done with the
|
| 3647 | * connector.
|
| 3648 | *
|
| 3649 | * Returns: A reference to the found connector or an ERR_PTR().
|
| 3650 |
|
| 3651 | struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode)
|
| 3652 | {
|
| 3653 | struct drm_connector *connector, *found = ERR_PTR(-ENODEV);
|
| 3654 |
|
| 3655 | if (!fwnode)
|
| 3656 | return ERR_PTR(-ENODEV);
|
| 3657 |
|
| 3658 | mutex_lock(&connector_list_lock);
|
| 3659 |
|
| 3660 | list_for_each_entry(connector, &connector_list, global_connector_list_entry) {
|
| 3661 | if (connector->fwnode == fwnode ||
|
| 3662 | (connector->fwnode && connector->fwnode->secondary == fwnode)) {
|
| 3663 | drm_connector_get(connector);
|
| 3664 | found = connector;
|
| 3665 | break;
|
| 3666 | }
|
| 3667 | }
|
| 3668 |
|
| 3669 | mutex_unlock(&connector_list_lock);
|
| 3670 |
|
| 3671 | return found;
|
| 3672 | }
|
| 3673 |
|
| 3674 | |
| 3675 | * drm_connector_oob_hotplug_event - Report out-of-band hotplug event to connector
|
| 3676 | * @connector_fwnode: fwnode_handle to report the event on
|
| 3677 | * @status: hot plug detect logical state
|
| 3678 | *
|
| 3679 | * On some hardware a hotplug event notification may come from outside the display
|
| 3680 | * driver / device. An example of this is some USB Type-C setups where the hardware
|
| 3681 | * muxes the DisplayPort data and aux-lines but does not pass the altmode HPD
|
| 3682 | * status bit to the GPU's DP HPD pin.
|
| 3683 | *
|
| 3684 | * This function can be used to report these out-of-band events after obtaining
|
| 3685 | * a drm_connector reference through calling drm_connector_find_by_fwnode().
|
| 3686 |
|
| 3687 | void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode,
|
| 3688 | enum drm_connector_status status)
|
| 3689 | {
|
| 3690 | struct drm_connector *connector;
|
| 3691 |
|
| 3692 | connector = drm_connector_find_by_fwnode(connector_fwnode);
|
| 3693 | if (IS_ERR(connector))
|
| 3694 | return;
|
| 3695 |
|
| 3696 | if (connector->funcs->oob_hotplug_event)
|
| 3697 | connector->funcs->oob_hotplug_event(connector, status);
|
| 3698 |
|
| 3699 | drm_connector_put(connector);
|
| 3700 | }
|
| 3701 | EXPORT_SYMBOL(drm_connector_oob_hotplug_event);
|
| 3702 |
|
| 3703 | |
| 3704 | * drm_connector_get_color_format - Return connector color format of @conn_state
|
| 3705 | * @conn_state: pointer to the &struct drm_connector_state to go check
|
| 3706 | *
|
| 3707 |
|
| 3708 | enum drm_connector_color_format
|
| 3709 | drm_connector_get_color_format(const struct drm_connector_state *conn_state)
|
| 3710 | {
|
| 3711 | struct drm_connector *connector = conn_state->connector;
|
| 3712 |
|
| 3713 | if (connector->funcs->color_format)
|
| 3714 | return connector->funcs->color_format(conn_state);
|
| 3715 |
|
| 3716 | return conn_state->color_format;
|
| 3717 | }
|
| 3718 | EXPORT_SYMBOL(drm_connector_get_color_format);
|
| 3719 |
|
| 3720 | |
| 3721 | * DOC: Tile group
|
| 3722 | *
|
| 3723 | * Tile groups are used to represent tiled monitors with a unique integer
|
| 3724 | * identifier. Tiled monitors using DisplayID v1.3 have a unique 8-byte handle,
|
| 3725 | * we store this in a tile group, so we have a common identifier for all tiles
|
| 3726 | * in a monitor group. The property is called "TILE". Drivers can manage tile
|
| 3727 | * groups using drm_mode_create_tile_group(), drm_mode_put_tile_group() and
|
| 3728 | * drm_mode_get_tile_group(). But this is only needed for internal panels where
|
| 3729 | * the tile group information is exposed through a non-standard way.
|
| 3730 |
|
| 3731 |
|
| 3732 | static void drm_tile_group_free(struct kref *kref)
|
| 3733 | {
|
| 3734 | struct drm_tile_group *tg = container_of(kref, struct drm_tile_group, refcount);
|
| 3735 | struct drm_device *dev = tg->dev;
|
| 3736 |
|
| 3737 | mutex_lock(&dev->mode_config.idr_mutex);
|
| 3738 | idr_remove(&dev->mode_config.tile_idr, tg->id);
|
| 3739 | mutex_unlock(&dev->mode_config.idr_mutex);
|
| 3740 | kfree(tg);
|
| 3741 | }
|
| 3742 |
|
| 3743 | |
| 3744 | * drm_mode_put_tile_group - drop a reference to a tile group.
|
| 3745 | * @dev: DRM device
|
| 3746 | * @tg: tile group to drop reference to.
|
| 3747 | *
|
| 3748 | * drop reference to tile group and free if 0.
|
| 3749 |
|
| 3750 | void drm_mode_put_tile_group(struct drm_device *dev,
|
| 3751 | struct drm_tile_group *tg)
|
| 3752 | {
|
| 3753 | kref_put(&tg->refcount, drm_tile_group_free);
|
| 3754 | }
|
| 3755 | EXPORT_SYMBOL(drm_mode_put_tile_group);
|
| 3756 |
|
| 3757 | |
| 3758 | * drm_mode_get_tile_group - get a reference to an existing tile group
|
| 3759 | * @dev: DRM device
|
| 3760 | * @topology_id: 9-byte unique ID per monitor.
|
| 3761 | *
|
| 3762 | * Use the unique bytes to get a reference to an existing tile group.
|
| 3763 | *
|
| 3764 | * RETURNS:
|
| 3765 | * tile group or NULL if not found.
|
| 3766 |
|
| 3767 | struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
|
| 3768 | const char topology_id[9])
|
| 3769 | {
|
| 3770 | struct drm_tile_group *tg;
|
| 3771 | int id;
|
| 3772 |
|
| 3773 | mutex_lock(&dev->mode_config.idr_mutex);
|
| 3774 | idr_for_each_entry(&dev->mode_config.tile_idr, tg, id) {
|
| 3775 | if (!memcmp(tg->group_data, topology_id, sizeof(tg->group_data))) {
|
| 3776 | if (!kref_get_unless_zero(&tg->refcount))
|
| 3777 | tg = NULL;
|
| 3778 | mutex_unlock(&dev->mode_config.idr_mutex);
|
| 3779 | return tg;
|
| 3780 | }
|
| 3781 | }
|
| 3782 | mutex_unlock(&dev->mode_config.idr_mutex);
|
| 3783 | return NULL;
|
| 3784 | }
|
| 3785 | EXPORT_SYMBOL(drm_mode_get_tile_group);
|
| 3786 |
|
| 3787 | |
| 3788 | * drm_mode_create_tile_group - create a tile group from a displayid description
|
| 3789 | * @dev: DRM device
|
| 3790 | * @topology_id: 9-byte unique ID per monitor.
|
| 3791 | *
|
| 3792 | * Create a tile group for the unique monitor, and get a unique
|
| 3793 | * identifier for the tile group.
|
| 3794 | *
|
| 3795 | * RETURNS:
|
| 3796 | * new tile group or NULL.
|
| 3797 |
|
| 3798 | struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
|
| 3799 | const char topology_id[9])
|
| 3800 | {
|
| 3801 | struct drm_tile_group *tg;
|
| 3802 | int ret;
|
| 3803 |
|
| 3804 | tg = kzalloc_obj(*tg);
|
| 3805 | if (!tg)
|
| 3806 | return NULL;
|
| 3807 |
|
| 3808 | kref_init(&tg->refcount);
|
| 3809 | memcpy(tg->group_data, topology_id, sizeof(tg->group_data));
|
| 3810 | tg->dev = dev;
|
| 3811 |
|
| 3812 | mutex_lock(&dev->mode_config.idr_mutex);
|
| 3813 | ret = idr_alloc(&dev->mode_config.tile_idr, tg, 1, 0, GFP_KERNEL);
|
| 3814 | if (ret >= 0) {
|
| 3815 | tg->id = ret;
|
| 3816 | } else {
|
| 3817 | kfree(tg);
|
| 3818 | tg = NULL;
|
| 3819 | }
|
| 3820 |
|
| 3821 | mutex_unlock(&dev->mode_config.idr_mutex);
|
| 3822 | return tg;
|
| 3823 | }
|
| 3824 | EXPORT_SYMBOL(drm_mode_create_tile_group);
|
| 3825 |
|
| 3826 | |
| 3827 | * drm_connector_attach_panel_type_property - attaches panel type property
|
| 3828 | * @connector: connector to attach the property on.
|
| 3829 | *
|
| 3830 | * This is used to add support for panel type detection.
|
| 3831 |
|
| 3832 | void drm_connector_attach_panel_type_property(struct drm_connector *connector)
|
| 3833 | {
|
| 3834 | struct drm_device *dev = connector->dev;
|
| 3835 | struct drm_property *prop = dev->mode_config.panel_type_property;
|
| 3836 |
|
| 3837 | if (!prop)
|
| 3838 | return;
|
| 3839 |
|
| 3840 | drm_object_attach_property(&connector->base, prop, DRM_MODE_PANEL_TYPE_UNKNOWN);
|
| 3841 | }
|
| 3842 | EXPORT_SYMBOL(drm_connector_attach_panel_type_property);
|