Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'topic/drm-misc-2016-08-23' of git://anongit.freedesktop.org/drm-intel into drm-next

A few bigger things:
- start of splitting drm_crtc.c into more manageable and better documneted
chunks
- DRM_DEV_* logging (Sean)

* tag 'topic/drm-misc-2016-08-23' of git://anongit.freedesktop.org/drm-intel: (46 commits)
drm/fb-helper: Make docs for fb_set_suspend wrappers consistent
drm/rockchip: Delete unnecessary assignment for the field "owner"
drm/bridge: dw-hdmi: Delete unnecessary assignment for the field "owner"
drm/rockchip: Don't continue trying to enable crtc on failure
drm/fb-helper: Add drm_fb_helper_set_suspend_unlocked()
drm/fb-helper: Fix the dummy remove_conflicting_framebuffers
drm/udl: Ensure channel is selected before using the device.
drm: Avoid calling dev_printk(.dev = NULL)
drm: avoid exposing kernel stack in compat_drm_getstats
reservation: fix small comment typo
drm: Don't implement empty prepare_fb()/cleanup_fb()
virtio-gpu: Use memdup_user() rather than duplicating its implementation
GPU-DRM-Savage: Use memdup_user() rather than duplicating
drm: Allow drivers to modify plane_state in prepare_fb/cleanup_fb
drm/rockchip: Use DRM_DEV_ERROR in vop
drm: Introduce DRM_DEV_* log messages
drm/edid: CEA mode 64 1080p100 vsync pulse width incorrect
Revert "drm/hisilicon: Don't set drm_device->platformdev"
dma-buf: fix kernel-doc warning and typos
drm: Fix kerneldoc in drm_plane_helper.c
...

+4183 -3860
+111 -102
Documentation/gpu/drm-kms-helpers.rst
··· 2 2 Mode Setting Helper Functions 3 3 ============================= 4 4 5 - The plane, CRTC, encoder and connector functions provided by the drivers 6 - implement the DRM API. They're called by the DRM core and ioctl handlers 7 - to handle device state changes and configuration request. As 8 - implementing those functions often requires logic not specific to 9 - drivers, mid-layer helper functions are available to avoid duplicating 10 - boilerplate code. 5 + The DRM subsystem aims for a strong separation between core code and helper 6 + libraries. Core code takes care of general setup and teardown and decoding 7 + userspace requests to kernel internal objects. Everything else is handled by a 8 + large set of helper libraries, which can be combined freely to pick and choose 9 + for each driver what fits, and avoid shared code where special behaviour is 10 + needed. 11 11 12 - The DRM core contains one mid-layer implementation. The mid-layer 13 - provides implementations of several plane, CRTC, encoder and connector 14 - functions (called from the top of the mid-layer) that pre-process 15 - requests and call lower-level functions provided by the driver (at the 16 - bottom of the mid-layer). For instance, the 17 - :c:func:`drm_crtc_helper_set_config()` function can be used to 18 - fill the :c:type:`struct drm_crtc_funcs <drm_crtc_funcs>` 19 - set_config field. When called, it will split the set_config operation 20 - in smaller, simpler operations and call the driver to handle them. 12 + This distinction between core code and helpers is especially strong in the 13 + modesetting code, where there's a shared userspace ABI for all drivers. This is 14 + in contrast to the render side, where pretty much everything (with very few 15 + exceptions) can be considered optional helper code. 21 16 22 - To use the mid-layer, drivers call 23 - :c:func:`drm_crtc_helper_add()`, 24 - :c:func:`drm_encoder_helper_add()` and 25 - :c:func:`drm_connector_helper_add()` functions to install their 26 - mid-layer bottom operations handlers, and fill the :c:type:`struct 27 - drm_crtc_funcs <drm_crtc_funcs>`, :c:type:`struct 28 - drm_encoder_funcs <drm_encoder_funcs>` and :c:type:`struct 29 - drm_connector_funcs <drm_connector_funcs>` structures with 30 - pointers to the mid-layer top API functions. Installing the mid-layer 31 - bottom operation handlers is best done right after registering the 32 - corresponding KMS object. 17 + There are a few areas these helpers can grouped into: 33 18 34 - The mid-layer is not split between CRTC, encoder and connector 35 - operations. To use it, a driver must provide bottom functions for all of 36 - the three KMS entities. 19 + * Helpers to implement modesetting. The important ones here are the atomic 20 + helpers. Old drivers still often use the legacy CRTC helpers. They both share 21 + the same set of common helper vtables. For really simple drivers (anything 22 + that would have been a great fit in the deprecated fbdev subsystem) there's 23 + also the simple display pipe helpers. 24 + 25 + * There's a big pile of helpers for handling outputs. First the generic bridge 26 + helpers for handling encoder and transcoder IP blocks. Second the panel helpers 27 + for handling panel-related information and logic. Plus then a big set of 28 + helpers for the various sink standards (DisplayPort, HDMI, MIPI DSI). Finally 29 + there's also generic helpers for handling output probing, and for dealing with 30 + EDIDs. 31 + 32 + * The last group of helpers concerns itself with the frontend side of a display 33 + pipeline: Planes, handling rectangles for visibility checking and scissoring, 34 + flip queues and assorted bits. 35 + 36 + Modeset Helper Reference for Common Vtables 37 + =========================================== 38 + 39 + .. kernel-doc:: include/drm/drm_modeset_helper_vtables.h 40 + :internal: 41 + 42 + .. kernel-doc:: include/drm/drm_modeset_helper_vtables.h 43 + :doc: overview 37 44 38 45 Atomic Modeset Helper Functions Reference 39 46 ========================================= ··· 69 62 .. kernel-doc:: drivers/gpu/drm/drm_atomic_helper.c 70 63 :export: 71 64 72 - Modeset Helper Reference for Common Vtables 73 - =========================================== 74 - 75 - .. kernel-doc:: include/drm/drm_modeset_helper_vtables.h 76 - :internal: 77 - 78 - .. kernel-doc:: include/drm/drm_modeset_helper_vtables.h 79 - :doc: overview 80 - 81 65 Legacy CRTC/Modeset Helper Functions Reference 82 66 ============================================== 83 67 84 68 .. kernel-doc:: drivers/gpu/drm/drm_crtc_helper.c 85 - :export: 86 - 87 - .. kernel-doc:: drivers/gpu/drm/drm_crtc_helper.c 88 69 :doc: overview 89 70 90 - Output Probing Helper Functions Reference 91 - ========================================= 92 - 93 - .. kernel-doc:: drivers/gpu/drm/drm_probe_helper.c 94 - :doc: output probing helper overview 95 - 96 - .. kernel-doc:: drivers/gpu/drm/drm_probe_helper.c 71 + .. kernel-doc:: drivers/gpu/drm/drm_crtc_helper.c 97 72 :export: 73 + 74 + Simple KMS Helper Reference 75 + =========================== 76 + 77 + .. kernel-doc:: include/drm/drm_simple_kms_helper.h 78 + :internal: 79 + 80 + .. kernel-doc:: drivers/gpu/drm/drm_simple_kms_helper.c 81 + :export: 82 + 83 + .. kernel-doc:: drivers/gpu/drm/drm_simple_kms_helper.c 84 + :doc: overview 98 85 99 86 fbdev Helper Functions Reference 100 87 ================================ ··· 110 109 111 110 .. kernel-doc:: drivers/gpu/drm/drm_fb_cma_helper.c 112 111 :export: 112 + 113 + Bridges 114 + ======= 115 + 116 + Overview 117 + -------- 118 + 119 + .. kernel-doc:: drivers/gpu/drm/drm_bridge.c 120 + :doc: overview 121 + 122 + Default bridge callback sequence 123 + -------------------------------- 124 + 125 + .. kernel-doc:: drivers/gpu/drm/drm_bridge.c 126 + :doc: bridge callbacks 127 + 128 + .. kernel-doc:: drivers/gpu/drm/drm_bridge.c 129 + :export: 130 + 131 + Panel Helper Reference 132 + ====================== 133 + 134 + .. kernel-doc:: include/drm/drm_panel.h 135 + :internal: 136 + 137 + .. kernel-doc:: drivers/gpu/drm/drm_panel.c 138 + :export: 139 + 140 + .. kernel-doc:: drivers/gpu/drm/drm_panel.c 141 + :doc: drm panel 113 142 114 143 Display Port Helper Functions Reference 115 144 ======================================= ··· 189 158 .. kernel-doc:: drivers/gpu/drm/drm_mipi_dsi.c 190 159 :export: 191 160 161 + Output Probing Helper Functions Reference 162 + ========================================= 163 + 164 + .. kernel-doc:: drivers/gpu/drm/drm_probe_helper.c 165 + :doc: output probing helper overview 166 + 167 + .. kernel-doc:: drivers/gpu/drm/drm_probe_helper.c 168 + :export: 169 + 192 170 EDID Helper Functions Reference 193 171 =============================== 194 172 ··· 216 176 .. kernel-doc:: drivers/gpu/drm/drm_rect.c 217 177 :export: 218 178 219 - Flip-work Helper Reference 220 - ========================== 221 - 222 - .. kernel-doc:: include/drm/drm_flip_work.h 223 - :doc: flip utils 224 - 225 - .. kernel-doc:: include/drm/drm_flip_work.h 226 - :internal: 227 - 228 - .. kernel-doc:: drivers/gpu/drm/drm_flip_work.c 229 - :export: 230 - 231 179 HDMI Infoframes Helper Reference 232 180 ================================ 233 181 ··· 230 202 .. kernel-doc:: drivers/video/hdmi.c 231 203 :export: 232 204 205 + Flip-work Helper Reference 206 + ========================== 207 + 208 + .. kernel-doc:: include/drm/drm_flip_work.h 209 + :doc: flip utils 210 + 211 + .. kernel-doc:: include/drm/drm_flip_work.h 212 + :internal: 213 + 214 + .. kernel-doc:: drivers/gpu/drm/drm_flip_work.c 215 + :export: 216 + 233 217 Plane Helper Reference 234 218 ====================== 235 219 236 220 .. kernel-doc:: drivers/gpu/drm/drm_plane_helper.c 237 - :export: 238 - 239 - .. kernel-doc:: drivers/gpu/drm/drm_plane_helper.c 240 221 :doc: overview 241 222 223 + .. kernel-doc:: drivers/gpu/drm/drm_plane_helper.c 224 + :export: 225 + 242 226 Tile group 243 - ---------- 227 + ========== 228 + 229 + # FIXME: This should probably be moved into a property documentation section 244 230 245 231 .. kernel-doc:: drivers/gpu/drm/drm_crtc.c 246 232 :doc: Tile group 247 233 248 - Bridges 249 - ======= 234 + Auxiliary Modeset Helpers 235 + ========================= 250 236 251 - Overview 252 - -------- 237 + .. kernel-doc:: drivers/gpu/drm/drm_modeset_helper.c 238 + :doc: aux kms helpers 253 239 254 - .. kernel-doc:: drivers/gpu/drm/drm_bridge.c 255 - :doc: overview 256 - 257 - Default bridge callback sequence 258 - -------------------------------- 259 - 260 - .. kernel-doc:: drivers/gpu/drm/drm_bridge.c 261 - :doc: bridge callbacks 262 - 263 - .. kernel-doc:: drivers/gpu/drm/drm_bridge.c 240 + .. kernel-doc:: drivers/gpu/drm/drm_modeset_helper.c 264 241 :export: 265 - 266 - Panel Helper Reference 267 - ====================== 268 - 269 - .. kernel-doc:: include/drm/drm_panel.h 270 - :internal: 271 - 272 - .. kernel-doc:: drivers/gpu/drm/drm_panel.c 273 - :export: 274 - 275 - .. kernel-doc:: drivers/gpu/drm/drm_panel.c 276 - :doc: drm panel 277 - 278 - Simple KMS Helper Reference 279 - =========================== 280 - 281 - .. kernel-doc:: include/drm/drm_simple_kms_helper.h 282 - :internal: 283 - 284 - .. kernel-doc:: drivers/gpu/drm/drm_simple_kms_helper.c 285 - :export: 286 - 287 - .. kernel-doc:: drivers/gpu/drm/drm_simple_kms_helper.c 288 - :doc: overview
+50 -214
Documentation/gpu/drm-kms.rst
··· 2 2 Kernel Mode Setting (KMS) 3 3 ========================= 4 4 5 - Mode Setting 6 - ============ 7 - 8 5 Drivers must initialize the mode setting core by calling 9 6 :c:func:`drm_mode_config_init()` on the DRM device. The function 10 7 initializes the :c:type:`struct drm_device <drm_device>` ··· 15 18 - struct drm_mode_config_funcs \*funcs; 16 19 Mode setting functions. 17 20 18 - Display Modes Function Reference 19 - -------------------------------- 21 + KMS Data Structures 22 + =================== 20 23 21 - .. kernel-doc:: include/drm/drm_modes.h 24 + .. kernel-doc:: include/drm/drm_crtc.h 22 25 :internal: 23 26 24 - .. kernel-doc:: drivers/gpu/drm/drm_modes.c 27 + KMS API Functions 28 + ================= 29 + 30 + .. kernel-doc:: drivers/gpu/drm/drm_crtc.c 25 31 :export: 26 32 27 33 Atomic Mode Setting Function Reference 28 - -------------------------------------- 34 + ====================================== 29 35 30 36 .. kernel-doc:: drivers/gpu/drm/drm_atomic.c 31 37 :export: 32 38 33 - .. kernel-doc:: drivers/gpu/drm/drm_atomic.c 39 + .. kernel-doc:: include/drm/drm_atomic.h 34 40 :internal: 35 41 36 42 Frame Buffer Abstraction 37 - ------------------------ 43 + ======================== 38 44 39 - Frame buffers are abstract memory objects that provide a source of 40 - pixels to scanout to a CRTC. Applications explicitly request the 41 - creation of frame buffers through the DRM_IOCTL_MODE_ADDFB(2) ioctls 42 - and receive an opaque handle that can be passed to the KMS CRTC control, 43 - plane configuration and page flip functions. 45 + .. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c 46 + :doc: overview 44 47 45 - Frame buffers rely on the underneath memory manager for low-level memory 46 - operations. When creating a frame buffer applications pass a memory 47 - handle (or a list of memory handles for multi-planar formats) through 48 - the ``drm_mode_fb_cmd2`` argument. For drivers using GEM as their 49 - userspace buffer management interface this would be a GEM handle. 50 - Drivers are however free to use their own backing storage object 51 - handles, e.g. vmwgfx directly exposes special TTM handles to userspace 52 - and so expects TTM handles in the create ioctl and not GEM handles. 48 + Frame Buffer Functions Reference 49 + -------------------------------- 53 50 54 - The lifetime of a drm framebuffer is controlled with a reference count, 55 - drivers can grab additional references with 56 - :c:func:`drm_framebuffer_reference()`and drop them again with 57 - :c:func:`drm_framebuffer_unreference()`. For driver-private 58 - framebuffers for which the last reference is never dropped (e.g. for the 59 - fbdev framebuffer when the struct :c:type:`struct drm_framebuffer 60 - <drm_framebuffer>` is embedded into the fbdev helper struct) 61 - drivers can manually clean up a framebuffer at module unload time with 62 - :c:func:`drm_framebuffer_unregister_private()`. 51 + .. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c 52 + :export: 53 + 54 + .. kernel-doc:: include/drm/drm_framebuffer.h 55 + :internal: 63 56 64 57 DRM Format Handling 65 - ------------------- 58 + =================== 66 59 67 60 .. kernel-doc:: drivers/gpu/drm/drm_fourcc.c 68 61 :export: 69 62 70 63 Dumb Buffer Objects 71 - ------------------- 64 + =================== 72 65 73 66 The KMS API doesn't standardize backing storage object creation and 74 67 leaves it to driver-specific ioctls. Furthermore actually creating a ··· 101 114 attempted on some ARM embedded platforms. Such drivers really must have 102 115 a hardware-specific ioctl to allocate suitable buffer objects. 103 116 104 - Output Polling 105 - -------------- 117 + Display Modes Function Reference 118 + ================================ 106 119 107 - void (\*output_poll_changed)(struct drm_device \*dev); 108 - This operation notifies the driver that the status of one or more 109 - connectors has changed. Drivers that use the fb helper can just call the 110 - :c:func:`drm_fb_helper_hotplug_event()` function to handle this 111 - operation. 120 + .. kernel-doc:: include/drm/drm_modes.h 121 + :internal: 122 + 123 + .. kernel-doc:: drivers/gpu/drm/drm_modes.c 124 + :export: 125 + 126 + Connector Abstraction 127 + ===================== 128 + 129 + .. kernel-doc:: drivers/gpu/drm/drm_connector.c 130 + :doc: overview 131 + 132 + Connector Functions Reference 133 + ----------------------------- 134 + 135 + .. kernel-doc:: include/drm/drm_connector.h 136 + :internal: 137 + 138 + .. kernel-doc:: drivers/gpu/drm/drm_connector.c 139 + :export: 112 140 113 141 KMS Initialization and Cleanup 114 142 ============================== ··· 238 236 compatibility layer when implemented) are responsible for attaching the 239 237 encoders they want to use to a CRTC. 240 238 241 - Connectors (:c:type:`struct drm_connector <drm_connector>`) 242 - ----------------------------------------------------------- 243 - 244 - A connector is the final destination for pixel data on a device, and 245 - usually connects directly to an external display device like a monitor 246 - or laptop panel. A connector can only be attached to one encoder at a 247 - time. The connector is also the structure where information about the 248 - attached display is kept, so it contains fields for display data, EDID 249 - data, DPMS & connection status, and information about modes supported on 250 - the attached displays. 251 - 252 - Connector Initialization 253 - ~~~~~~~~~~~~~~~~~~~~~~~~ 254 - 255 - Finally a KMS driver must create, initialize, register and attach at 256 - least one :c:type:`struct drm_connector <drm_connector>` 257 - instance. The instance is created as other KMS objects and initialized 258 - by setting the following fields. 259 - 260 - interlace_allowed 261 - Whether the connector can handle interlaced modes. 262 - 263 - doublescan_allowed 264 - Whether the connector can handle doublescan. 265 - 266 - display_info 267 - Display information is filled from EDID information when a display 268 - is detected. For non hot-pluggable displays such as flat panels in 269 - embedded systems, the driver should initialize the 270 - display_info.width_mm and display_info.height_mm fields with the 271 - physical size of the display. 272 - 273 - polled 274 - Connector polling mode, a combination of 275 - 276 - DRM_CONNECTOR_POLL_HPD 277 - The connector generates hotplug events and doesn't need to be 278 - periodically polled. The CONNECT and DISCONNECT flags must not 279 - be set together with the HPD flag. 280 - 281 - DRM_CONNECTOR_POLL_CONNECT 282 - Periodically poll the connector for connection. 283 - 284 - DRM_CONNECTOR_POLL_DISCONNECT 285 - Periodically poll the connector for disconnection. 286 - 287 - Set to 0 for connectors that don't support connection status 288 - discovery. 289 - 290 - The connector is then registered with a call to 291 - :c:func:`drm_connector_init()` with a pointer to the connector 292 - functions and a connector type, and exposed through sysfs with a call to 293 - :c:func:`drm_connector_register()`. 294 - 295 - Supported connector types are 296 - 297 - - DRM_MODE_CONNECTOR_VGA 298 - - DRM_MODE_CONNECTOR_DVII 299 - - DRM_MODE_CONNECTOR_DVID 300 - - DRM_MODE_CONNECTOR_DVIA 301 - - DRM_MODE_CONNECTOR_Composite 302 - - DRM_MODE_CONNECTOR_SVIDEO 303 - - DRM_MODE_CONNECTOR_LVDS 304 - - DRM_MODE_CONNECTOR_Component 305 - - DRM_MODE_CONNECTOR_9PinDIN 306 - - DRM_MODE_CONNECTOR_DisplayPort 307 - - DRM_MODE_CONNECTOR_HDMIA 308 - - DRM_MODE_CONNECTOR_HDMIB 309 - - DRM_MODE_CONNECTOR_TV 310 - - DRM_MODE_CONNECTOR_eDP 311 - - DRM_MODE_CONNECTOR_VIRTUAL 312 - 313 - Connectors must be attached to an encoder to be used. For devices that 314 - map connectors to encoders 1:1, the connector should be attached at 315 - initialization time with a call to 316 - :c:func:`drm_mode_connector_attach_encoder()`. The driver must 317 - also set the :c:type:`struct drm_connector <drm_connector>` 318 - encoder field to point to the attached encoder. 319 - 320 - Finally, drivers must initialize the connectors state change detection 321 - with a call to :c:func:`drm_kms_helper_poll_init()`. If at least 322 - one connector is pollable but can't generate hotplug interrupts 323 - (indicated by the DRM_CONNECTOR_POLL_CONNECT and 324 - DRM_CONNECTOR_POLL_DISCONNECT connector flags), a delayed work will 325 - automatically be queued to periodically poll for changes. Connectors 326 - that can generate hotplug interrupts must be marked with the 327 - DRM_CONNECTOR_POLL_HPD flag instead, and their interrupt handler must 328 - call :c:func:`drm_helper_hpd_irq_event()`. The function will 329 - queue a delayed work to check the state of all connectors, but no 330 - periodic polling will be done. 331 - 332 - Connector Operations 333 - ~~~~~~~~~~~~~~~~~~~~ 334 - 335 - **Note** 336 - 337 - Unless otherwise state, all operations are mandatory. 338 - 339 - DPMS 340 - '''' 341 - 342 - void (\*dpms)(struct drm_connector \*connector, int mode); 343 - The DPMS operation sets the power state of a connector. The mode 344 - argument is one of 345 - 346 - - DRM_MODE_DPMS_ON 347 - 348 - - DRM_MODE_DPMS_STANDBY 349 - 350 - - DRM_MODE_DPMS_SUSPEND 351 - 352 - - DRM_MODE_DPMS_OFF 353 - 354 - In all but DPMS_ON mode the encoder to which the connector is attached 355 - should put the display in low-power mode by driving its signals 356 - appropriately. If more than one connector is attached to the encoder 357 - care should be taken not to change the power state of other displays as 358 - a side effect. Low-power mode should be propagated to the encoders and 359 - CRTCs when all related connectors are put in low-power mode. 360 - 361 - Modes 362 - ''''' 363 - 364 - int (\*fill_modes)(struct drm_connector \*connector, uint32_t 365 - max_width, uint32_t max_height); 366 - Fill the mode list with all supported modes for the connector. If the 367 - ``max_width`` and ``max_height`` arguments are non-zero, the 368 - implementation must ignore all modes wider than ``max_width`` or higher 369 - than ``max_height``. 370 - 371 - The connector must also fill in this operation its display_info 372 - width_mm and height_mm fields with the connected display physical size 373 - in millimeters. The fields should be set to 0 if the value isn't known 374 - or is not applicable (for instance for projector devices). 375 - 376 - Connection Status 377 - ''''''''''''''''' 378 - 379 - The connection status is updated through polling or hotplug events when 380 - supported (see ?). The status value is reported to userspace through 381 - ioctls and must not be used inside the driver, as it only gets 382 - initialized by a call to :c:func:`drm_mode_getconnector()` from 383 - userspace. 384 - 385 - enum drm_connector_status (\*detect)(struct drm_connector 386 - \*connector, bool force); 387 - Check to see if anything is attached to the connector. The ``force`` 388 - parameter is set to false whilst polling or to true when checking the 389 - connector due to user request. ``force`` can be used by the driver to 390 - avoid expensive, destructive operations during automated probing. 391 - 392 - Return connector_status_connected if something is connected to the 393 - connector, connector_status_disconnected if nothing is connected and 394 - connector_status_unknown if the connection state isn't known. 395 - 396 - Drivers should only return connector_status_connected if the 397 - connection status has really been probed as connected. Connectors that 398 - can't detect the connection status, or failed connection status probes, 399 - should return connector_status_unknown. 400 - 401 239 Cleanup 402 240 ------- 403 241 ··· 305 463 the process is complete, the new connector is registered with sysfs to 306 464 make its properties available to applications. 307 465 308 - KMS API Functions 309 - ----------------- 310 - 311 - .. kernel-doc:: drivers/gpu/drm/drm_crtc.c 312 - :export: 313 - 314 - KMS Data Structures 315 - ------------------- 316 - 317 - .. kernel-doc:: include/drm/drm_crtc.h 318 - :internal: 319 - 320 466 KMS Locking 321 - ----------- 467 + =========== 322 468 323 469 .. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c 324 470 :doc: kms locking ··· 404 574 :c:func:`drm_object_attach_property()`. The function takes a 405 575 pointer to the target object, a pointer to the previously created 406 576 property and an initial instance value. 577 + 578 + Blending and Z-Position properties 579 + ---------------------------------- 580 + 581 + .. kernel-doc:: drivers/gpu/drm/drm_blend.c 582 + :export: 407 583 408 584 Existing KMS Properties 409 585 -----------------------
+29 -29
Documentation/gpu/drm-mm.rst
··· 26 26 UMA devices. 27 27 28 28 The Translation Table Manager (TTM) 29 - ----------------------------------- 29 + =================================== 30 30 31 31 TTM design background and information belongs here. 32 32 33 33 TTM initialization 34 - ~~~~~~~~~~~~~~~~~~ 34 + ------------------ 35 35 36 36 **Warning** 37 37 ··· 77 77 count for the TTM, which will call your initialization function. 78 78 79 79 The Graphics Execution Manager (GEM) 80 - ------------------------------------ 80 + ==================================== 81 81 82 82 The GEM design approach has resulted in a memory manager that doesn't 83 83 provide full coverage of all (or even all common) use cases in its ··· 114 114 driver-specific ioctls. 115 115 116 116 GEM Initialization 117 - ~~~~~~~~~~~~~~~~~~ 117 + ------------------ 118 118 119 119 Drivers that use GEM must set the DRIVER_GEM bit in the struct 120 120 :c:type:`struct drm_driver <drm_driver>` driver_features ··· 132 132 its own DRM MM object. 133 133 134 134 GEM Objects Creation 135 - ~~~~~~~~~~~~~~~~~~~~ 135 + -------------------- 136 136 137 137 GEM splits creation of GEM objects and allocation of the memory that 138 138 backs them in two distinct operations. ··· 173 173 must be managed by drivers. 174 174 175 175 GEM Objects Lifetime 176 - ~~~~~~~~~~~~~~~~~~~~ 176 + -------------------- 177 177 178 178 All GEM objects are reference-counted by the GEM core. References can be 179 179 acquired and release by :c:func:`calling ··· 196 196 :c:func:`drm_gem_object_release()`. 197 197 198 198 GEM Objects Naming 199 - ~~~~~~~~~~~~~~~~~~ 199 + ------------------ 200 200 201 201 Communication between userspace and the kernel refers to GEM objects 202 202 using local handles, global names or, more recently, file descriptors. ··· 245 245 based on dma-bufs. 246 246 247 247 GEM Objects Mapping 248 - ~~~~~~~~~~~~~~~~~~~ 248 + ------------------- 249 249 250 250 Because mapping operations are fairly heavyweight GEM favours 251 251 read/write-like access to buffers, implemented through driver-specific ··· 304 304 faults can implement their own mmap file operation handler. 305 305 306 306 Memory Coherency 307 - ~~~~~~~~~~~~~~~~ 307 + ---------------- 308 308 309 309 When mapped to the device or used in a command buffer, backing pages for 310 310 an object are flushed to memory and marked write combined so as to be ··· 320 320 any necessary flushing operations). 321 321 322 322 Command Execution 323 - ~~~~~~~~~~~~~~~~~ 323 + ----------------- 324 324 325 325 Perhaps the most important GEM function for GPU devices is providing a 326 326 command execution interface to clients. Client programs construct ··· 348 348 .. kernel-doc:: include/drm/drm_gem.h 349 349 :internal: 350 350 351 + GEM CMA Helper Functions Reference 352 + ---------------------------------- 353 + 354 + .. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c 355 + :doc: cma helpers 356 + 357 + .. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c 358 + :export: 359 + 360 + .. kernel-doc:: include/drm/drm_gem_cma_helper.h 361 + :internal: 362 + 351 363 VMA Offset Manager 352 - ------------------ 364 + ================== 353 365 354 366 .. kernel-doc:: drivers/gpu/drm/drm_vma_manager.c 355 367 :doc: vma offset manager ··· 373 361 :internal: 374 362 375 363 PRIME Buffer Sharing 376 - -------------------- 364 + ==================== 377 365 378 366 PRIME is the cross device buffer sharing framework in drm, originally 379 367 created for the OPTIMUS range of multi-gpu platforms. To userspace PRIME 380 368 buffers are dma-buf based file descriptors. 381 369 382 370 Overview and Driver Interface 383 - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 371 + ----------------------------- 384 372 385 373 Similar to GEM global names, PRIME file descriptors are also used to 386 374 share buffer objects across processes. They offer additional security: ··· 418 406 support PRIME. 419 407 420 408 PRIME Helper Functions 421 - ~~~~~~~~~~~~~~~~~~~~~~ 409 + ---------------------- 422 410 423 411 .. kernel-doc:: drivers/gpu/drm/drm_prime.c 424 412 :doc: PRIME Helpers ··· 430 418 :export: 431 419 432 420 DRM MM Range Allocator 433 - ---------------------- 421 + ====================== 434 422 435 423 Overview 436 - ~~~~~~~~ 424 + -------- 437 425 438 426 .. kernel-doc:: drivers/gpu/drm/drm_mm.c 439 427 :doc: Overview 440 428 441 429 LRU Scan/Eviction Support 442 - ~~~~~~~~~~~~~~~~~~~~~~~~~ 430 + ------------------------- 443 431 444 432 .. kernel-doc:: drivers/gpu/drm/drm_mm.c 445 433 :doc: lru scan roaster ··· 451 439 :export: 452 440 453 441 .. kernel-doc:: include/drm/drm_mm.h 454 - :internal: 455 - 456 - CMA Helper Functions Reference 457 - ------------------------------ 458 - 459 - .. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c 460 - :doc: cma helpers 461 - 462 - .. kernel-doc:: drivers/gpu/drm/drm_gem_cma_helper.c 463 - :export: 464 - 465 - .. kernel-doc:: include/drm/drm_gem_cma_helper.h 466 442 :internal:
+3
Documentation/gpu/drm-uapi.rst
··· 33 33 .. kernel-doc:: include/drm/drm_auth.h 34 34 :internal: 35 35 36 + Open-Source Userspace Requirements 37 + ================================== 38 + 36 39 Render nodes 37 40 ============ 38 41
+1
Documentation/gpu/index.rst
··· 12 12 drm-uapi 13 13 i915 14 14 vga-switcheroo 15 + vgaarbiter
-2
Documentation/gpu/vga-switcheroo.rst
··· 1 - .. _vga_switcheroo: 2 - 3 1 ============== 4 2 VGA Switcheroo 5 3 ==============
+71 -72
Documentation/vgaarbiter.txt Documentation/gpu/vgaarbiter.rst
··· 1 - 1 + =========== 2 2 VGA Arbiter 3 3 =========== 4 4 ··· 19 19 is needed to control the sharing of these resources. This document introduces 20 20 the operation of the VGA arbiter implemented for the Linux kernel. 21 21 22 - ---------------------------------------------------------------------------- 23 - 24 - I. Details and Theory of Operation 25 - I.1 vgaarb 26 - I.2 libpciaccess 27 - I.3 xf86VGAArbiter (X server implementation) 28 - II. Credits 29 - III.References 30 - 31 - 32 - I. Details and Theory of Operation 33 - ================================== 34 - 35 - I.1 vgaarb 36 - ---------- 22 + vgaarb kernel/userspace ABI 23 + --------------------------- 37 24 38 25 The vgaarb is a module of the Linux Kernel. When it is initially loaded, it 39 26 scans all PCI devices and adds the VGA ones inside the arbitration. The ··· 31 44 The kernel exports a char device interface (/dev/vga_arbiter) to the clients, 32 45 which has the following semantics: 33 46 34 - open : open user instance of the arbiter. By default, it's attached to 35 - the default VGA device of the system. 47 + open 48 + Opens a user instance of the arbiter. By default, it's attached to the 49 + default VGA device of the system. 36 50 37 - close : close user instance. Release locks made by the user 51 + close 52 + Close a user instance. Release locks made by the user 38 53 39 - read : return a string indicating the status of the target like: 54 + read 55 + Return a string indicating the status of the target like: 40 56 41 - "<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)" 57 + "<card_ID>,decodes=<io_state>,owns=<io_state>,locks=<io_state> (ic,mc)" 42 58 43 - An IO state string is of the form {io,mem,io+mem,none}, mc and 44 - ic are respectively mem and io lock counts (for debugging/ 45 - diagnostic only). "decodes" indicate what the card currently 46 - decodes, "owns" indicates what is currently enabled on it, and 47 - "locks" indicates what is locked by this card. If the card is 48 - unplugged, we get "invalid" then for card_ID and an -ENODEV 49 - error is returned for any command until a new card is targeted. 59 + An IO state string is of the form {io,mem,io+mem,none}, mc and 60 + ic are respectively mem and io lock counts (for debugging/ 61 + diagnostic only). "decodes" indicate what the card currently 62 + decodes, "owns" indicates what is currently enabled on it, and 63 + "locks" indicates what is locked by this card. If the card is 64 + unplugged, we get "invalid" then for card_ID and an -ENODEV 65 + error is returned for any command until a new card is targeted. 50 66 51 67 52 - write : write a command to the arbiter. List of commands: 68 + write 69 + Write a command to the arbiter. List of commands: 53 70 54 - target <card_ID> : switch target to card <card_ID> (see below) 55 - lock <io_state> : acquires locks on target ("none" is an invalid io_state) 56 - trylock <io_state> : non-blocking acquire locks on target (returns EBUSY if 57 - unsuccessful) 58 - unlock <io_state> : release locks on target 59 - unlock all : release all locks on target held by this user (not 60 - implemented yet) 61 - decodes <io_state> : set the legacy decoding attributes for the card 71 + target <card_ID> 72 + switch target to card <card_ID> (see below) 73 + lock <io_state> 74 + acquires locks on target ("none" is an invalid io_state) 75 + trylock <io_state> 76 + non-blocking acquire locks on target (returns EBUSY if 77 + unsuccessful) 78 + unlock <io_state> 79 + release locks on target 80 + unlock all 81 + release all locks on target held by this user (not implemented 82 + yet) 83 + decodes <io_state> 84 + set the legacy decoding attributes for the card 62 85 63 - poll : event if something changes on any card (not just the 64 - target) 86 + poll 87 + event if something changes on any card (not just the target) 65 88 66 - card_ID is of the form "PCI:domain:bus:dev.fn". It can be set to "default" 67 - to go back to the system default card (TODO: not implemented yet). Currently, 68 - only PCI is supported as a prefix, but the userland API may support other bus 69 - types in the future, even if the current kernel implementation doesn't. 89 + card_ID is of the form "PCI:domain:bus:dev.fn". It can be set to "default" 90 + to go back to the system default card (TODO: not implemented yet). Currently, 91 + only PCI is supported as a prefix, but the userland API may support other bus 92 + types in the future, even if the current kernel implementation doesn't. 70 93 71 94 Note about locks: 72 95 ··· 94 97 There is also an in-kernel API of the arbiter in case DRM, vgacon, or other 95 98 drivers want to use it. 96 99 100 + In-kernel interface 101 + ------------------- 97 102 98 - I.2 libpciaccess 99 - ---------------- 103 + .. kernel-doc:: include/linux/vgaarb.h 104 + :internal: 105 + 106 + .. kernel-doc:: drivers/gpu/vga/vgaarb.c 107 + :export: 108 + 109 + libpciaccess 110 + ------------ 100 111 101 112 To use the vga arbiter char device it was implemented an API inside the 102 113 libpciaccess library. One field was added to struct pci_device (each device 103 - on the system): 114 + on the system):: 104 115 105 116 /* the type of resource decoded by the device */ 106 117 int vgaarb_rsrc; 107 118 108 - Besides it, in pci_system were added: 119 + Besides it, in pci_system were added:: 109 120 110 121 int vgaarb_fd; 111 122 int vga_count; 112 123 struct pci_device *vga_target; 113 124 struct pci_device *vga_default_dev; 114 125 115 - 116 126 The vga_count is used to track how many cards are being arbitrated, so for 117 127 instance, if there is only one card, then it can completely escape arbitration. 118 - 119 128 120 129 These functions below acquire VGA resources for the given card and mark those 121 130 resources as locked. If the resources requested are "normal" (and not legacy) ··· 139 136 succeeds. vga_arb_trylock() will return (-EBUSY) instead of blocking. Nested 140 137 calls are supported (a per-resource counter is maintained). 141 138 139 + Set the target device of this client. :: 142 140 143 - Set the target device of this client. 144 141 int pci_device_vgaarb_set_target (struct pci_device *dev); 145 - 146 142 147 143 For instance, in x86 if two devices on the same bus want to lock different 148 144 resources, both will succeed (lock). If devices are in different buses and 149 - trying to lock different resources, only the first who tried succeeds. 145 + trying to lock different resources, only the first who tried succeeds. :: 146 + 150 147 int pci_device_vgaarb_lock (void); 151 148 int pci_device_vgaarb_trylock (void); 152 149 153 - Unlock resources of device. 150 + Unlock resources of device. :: 151 + 154 152 int pci_device_vgaarb_unlock (void); 155 153 156 154 Indicates to the arbiter if the card decodes legacy VGA IOs, legacy VGA 157 155 Memory, both, or none. All cards default to both, the card driver (fbdev for 158 156 example) should tell the arbiter if it has disabled legacy decoding, so the 159 157 card can be left out of the arbitration process (and can be safe to take 160 - interrupts at any time. 158 + interrupts at any time. :: 159 + 161 160 int pci_device_vgaarb_decodes (int new_vgaarb_rsrc); 162 161 163 - Connects to the arbiter device, allocates the struct 162 + Connects to the arbiter device, allocates the struct :: 163 + 164 164 int pci_device_vgaarb_init (void); 165 165 166 - Close the connection 166 + Close the connection :: 167 + 167 168 void pci_device_vgaarb_fini (void); 168 169 169 - 170 - I.3 xf86VGAArbiter (X server implementation) 171 - -------------------------------------------- 172 - 173 - (TODO) 170 + xf86VGAArbiter (X server implementation) 171 + ---------------------------------------- 174 172 175 173 X server basically wraps all the functions that touch VGA registers somehow. 176 174 177 - 178 - II. Credits 179 - =========== 175 + References 176 + ---------- 180 177 181 178 Benjamin Herrenschmidt (IBM?) started this work when he discussed such design 182 179 with the Xorg community in 2005 [1, 2]. In the end of 2007, Paulo Zanoni and ··· 185 182 implementation of the user space side [3]. Now (2009) Tiago Vignatti and Dave 186 183 Airlie finally put this work in shape and queued to Jesse Barnes' PCI tree. 187 184 188 - 189 - III. References 190 - ============== 191 - 192 - [0] http://cgit.freedesktop.org/xorg/xserver/commit/?id=4b42448a2388d40f257774fbffdccaea87bd0347 193 - [1] http://lists.freedesktop.org/archives/xorg/2005-March/006663.html 194 - [2] http://lists.freedesktop.org/archives/xorg/2005-March/006745.html 195 - [3] http://lists.freedesktop.org/archives/xorg/2007-October/029507.html 185 + 0) http://cgit.freedesktop.org/xorg/xserver/commit/?id=4b42448a2388d40f257774fbffdccaea87bd0347 186 + 1) http://lists.freedesktop.org/archives/xorg/2005-March/006663.html 187 + 2) http://lists.freedesktop.org/archives/xorg/2005-March/006745.html 188 + 3) http://lists.freedesktop.org/archives/xorg/2007-October/029507.html
+23
drivers/dma-buf/dma-buf.c
··· 586 586 } 587 587 EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment); 588 588 589 + static int __dma_buf_begin_cpu_access(struct dma_buf *dmabuf, 590 + enum dma_data_direction direction) 591 + { 592 + bool write = (direction == DMA_BIDIRECTIONAL || 593 + direction == DMA_TO_DEVICE); 594 + struct reservation_object *resv = dmabuf->resv; 595 + long ret; 596 + 597 + /* Wait on any implicit rendering fences */ 598 + ret = reservation_object_wait_timeout_rcu(resv, write, true, 599 + MAX_SCHEDULE_TIMEOUT); 600 + if (ret < 0) 601 + return ret; 602 + 603 + return 0; 604 + } 589 605 590 606 /** 591 607 * dma_buf_begin_cpu_access - Must be called before accessing a dma_buf from the ··· 623 607 624 608 if (dmabuf->ops->begin_cpu_access) 625 609 ret = dmabuf->ops->begin_cpu_access(dmabuf, direction); 610 + 611 + /* Ensure that all fences are waited upon - but we first allow 612 + * the native handler the chance to do so more efficiently if it 613 + * chooses. A double invocation here will be reasonably cheap no-op. 614 + */ 615 + if (ret == 0) 616 + ret = __dma_buf_begin_cpu_access(dmabuf, direction); 626 617 627 618 return ret; 628 619 }
+3 -3
drivers/dma-buf/fence-array.c
··· 107 107 * @fences: [in] array containing the fences 108 108 * @context: [in] fence context to use 109 109 * @seqno: [in] sequence number to use 110 - * @signal_on_any [in] signal on any fence in the array 110 + * @signal_on_any: [in] signal on any fence in the array 111 111 * 112 112 * Allocate a fence_array object and initialize the base fence with fence_init(). 113 113 * In case of error it returns NULL. 114 114 * 115 - * The caller should allocte the fences array with num_fences size 115 + * The caller should allocate the fences array with num_fences size 116 116 * and fill it with the fences it wants to add to the object. Ownership of this 117 - * array is take and fence_put() is used on each fence on release. 117 + * array is taken and fence_put() is used on each fence on release. 118 118 * 119 119 * If @signal_on_any is true the fence array signals if any fence in the array 120 120 * signals, otherwise it signals when all fences in the array signal.
+1 -1
drivers/dma-buf/reservation.c
··· 205 205 * @fence: the shared fence to add 206 206 * 207 207 * Add a fence to a shared slot, obj->lock must be held, and 208 - * reservation_object_reserve_shared_fence has been called. 208 + * reservation_object_reserve_shared() has been called. 209 209 */ 210 210 void reservation_object_add_shared_fence(struct reservation_object *obj, 211 211 struct fence *fence)
+3 -2
drivers/gpu/drm/Makefile
··· 12 12 drm_info.o drm_debugfs.o drm_encoder_slave.o \ 13 13 drm_trace_points.o drm_global.o drm_prime.o \ 14 14 drm_rect.o drm_vma_manager.o drm_flip_work.o \ 15 - drm_modeset_lock.o drm_atomic.o drm_bridge.o 15 + drm_modeset_lock.o drm_atomic.o drm_bridge.o \ 16 + drm_framebuffer.o drm_connector.o drm_blend.o 16 17 17 18 drm-$(CONFIG_COMPAT) += drm_ioc32.o 18 19 drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o ··· 25 24 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \ 26 25 drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \ 27 26 drm_kms_helper_common.o drm_dp_dual_mode_helper.o \ 28 - drm_simple_kms_helper.o drm_blend.o 27 + drm_simple_kms_helper.o drm_modeset_helper.o 29 28 30 29 drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o 31 30 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
+4 -2
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
··· 2071 2071 u32 tmp, viewport_w, viewport_h; 2072 2072 int r; 2073 2073 bool bypass_lut = false; 2074 + char *format_name; 2074 2075 2075 2076 /* no fb bound */ 2076 2077 if (!atomic && !crtc->primary->fb) { ··· 2183 2182 bypass_lut = true; 2184 2183 break; 2185 2184 default: 2186 - DRM_ERROR("Unsupported screen format %s\n", 2187 - drm_get_format_name(target_fb->pixel_format)); 2185 + format_name = drm_get_format_name(target_fb->pixel_format); 2186 + DRM_ERROR("Unsupported screen format %s\n", format_name); 2187 + kfree(format_name); 2188 2188 return -EINVAL; 2189 2189 } 2190 2190
+4 -2
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
··· 2046 2046 u32 tmp, viewport_w, viewport_h; 2047 2047 int r; 2048 2048 bool bypass_lut = false; 2049 + char *format_name; 2049 2050 2050 2051 /* no fb bound */ 2051 2052 if (!atomic && !crtc->primary->fb) { ··· 2158 2157 bypass_lut = true; 2159 2158 break; 2160 2159 default: 2161 - DRM_ERROR("Unsupported screen format %s\n", 2162 - drm_get_format_name(target_fb->pixel_format)); 2160 + format_name = drm_get_format_name(target_fb->pixel_format); 2161 + DRM_ERROR("Unsupported screen format %s\n", format_name); 2162 + kfree(format_name); 2163 2163 return -EINVAL; 2164 2164 } 2165 2165
+4 -2
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
··· 1952 1952 u32 viewport_w, viewport_h; 1953 1953 int r; 1954 1954 bool bypass_lut = false; 1955 + char *format_name; 1955 1956 1956 1957 /* no fb bound */ 1957 1958 if (!atomic && !crtc->primary->fb) { ··· 2057 2056 bypass_lut = true; 2058 2057 break; 2059 2058 default: 2060 - DRM_ERROR("Unsupported screen format %s\n", 2061 - drm_get_format_name(target_fb->pixel_format)); 2059 + format_name = drm_get_format_name(target_fb->pixel_format); 2060 + DRM_ERROR("Unsupported screen format %s\n", format_name); 2061 + kfree(format_name); 2062 2062 return -EINVAL; 2063 2063 } 2064 2064
-2
drivers/gpu/drm/arc/arcpgu_crtc.c
··· 183 183 } 184 184 185 185 static const struct drm_plane_helper_funcs arc_pgu_plane_helper_funcs = { 186 - .prepare_fb = NULL, 187 - .cleanup_fb = NULL, 188 186 .atomic_update = arc_pgu_plane_atomic_update, 189 187 }; 190 188
+1 -1
drivers/gpu/drm/armada/armada_drv.c
··· 211 211 .desc = "Armada SoC DRM", 212 212 .date = "20120730", 213 213 .driver_features = DRIVER_GEM | DRIVER_MODESET | 214 - DRIVER_HAVE_IRQ | DRIVER_PRIME, 214 + DRIVER_PRIME, 215 215 .ioctls = armada_ioctls, 216 216 .fops = &armada_drm_fops, 217 217 };
+2 -2
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
··· 755 755 } 756 756 757 757 static int atmel_hlcdc_plane_prepare_fb(struct drm_plane *p, 758 - const struct drm_plane_state *new_state) 758 + struct drm_plane_state *new_state) 759 759 { 760 760 /* 761 761 * FIXME: we should avoid this const -> non-const cast but it's ··· 780 780 } 781 781 782 782 static void atmel_hlcdc_plane_cleanup_fb(struct drm_plane *p, 783 - const struct drm_plane_state *old_state) 783 + struct drm_plane_state *old_state) 784 784 { 785 785 /* 786 786 * FIXME: we should avoid this const -> non-const cast but it's
-1
drivers/gpu/drm/bridge/dw-hdmi-ahb-audio.c
··· 640 640 .remove = snd_dw_hdmi_remove, 641 641 .driver = { 642 642 .name = DRIVER_NAME, 643 - .owner = THIS_MODULE, 644 643 .pm = PM_OPS, 645 644 }, 646 645 };
+3 -2
drivers/gpu/drm/drm_atomic.c
··· 837 837 /* Check whether this plane supports the fb pixel format. */ 838 838 ret = drm_plane_check_pixel_format(plane, state->fb->pixel_format); 839 839 if (ret) { 840 - DRM_DEBUG_ATOMIC("Invalid pixel format %s\n", 841 - drm_get_format_name(state->fb->pixel_format)); 840 + char *format_name = drm_get_format_name(state->fb->pixel_format); 841 + DRM_DEBUG_ATOMIC("Invalid pixel format %s\n", format_name); 842 + kfree(format_name); 842 843 return ret; 843 844 } 844 845
+1 -1
drivers/gpu/drm/drm_atomic_helper.c
··· 594 594 struct drm_plane_state *plane_state; 595 595 int i, ret = 0; 596 596 597 - ret = drm_atomic_helper_normalize_zpos(dev, state); 597 + ret = drm_atomic_normalize_zpos(dev, state); 598 598 if (ret) 599 599 return ret; 600 600
+4 -4
drivers/gpu/drm/drm_blend.c
··· 193 193 } 194 194 195 195 /** 196 - * drm_atomic_helper_normalize_zpos - calculate normalized zpos values for all 197 - * crtcs 196 + * drm_atomic_normalize_zpos - calculate normalized zpos values for all crtcs 198 197 * @dev: DRM device 199 198 * @state: atomic state of DRM device 200 199 * ··· 204 205 * RETURNS 205 206 * Zero for success or -errno 206 207 */ 207 - int drm_atomic_helper_normalize_zpos(struct drm_device *dev, 208 - struct drm_atomic_state *state) 208 + int drm_atomic_normalize_zpos(struct drm_device *dev, 209 + struct drm_atomic_state *state) 209 210 { 210 211 struct drm_crtc *crtc; 211 212 struct drm_crtc_state *crtc_state; ··· 235 236 } 236 237 return 0; 237 238 } 239 + EXPORT_SYMBOL(drm_atomic_normalize_zpos);
+1123
drivers/gpu/drm/drm_connector.c
··· 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/drmP.h> 24 + #include <drm/drm_connector.h> 25 + #include <drm/drm_edid.h> 26 + 27 + #include "drm_crtc_internal.h" 28 + #include "drm_internal.h" 29 + 30 + /** 31 + * DOC: overview 32 + * 33 + * In DRM connectors are the general abstraction for display sinks, and include 34 + * als fixed panels or anything else that can display pixels in some form. As 35 + * opposed to all other KMS objects representing hardware (like CRTC, encoder or 36 + * plane abstractions) connectors can be hotplugged and unplugged at runtime. 37 + * Hence they are reference-counted using drm_connector_reference() and 38 + * drm_connector_unreference(). 39 + * 40 + * KMS driver must create, initialize, register and attach at a struct 41 + * &drm_connector for each such sink. The instance is created as other KMS 42 + * objects and initialized by setting the following fields. 43 + * 44 + * The connector is then registered with a call to drm_connector_init() with a 45 + * pointer to the connector functions and a connector type, and exposed through 46 + * sysfs with a call to drm_connector_register(). 47 + * 48 + * Connectors must be attached to an encoder to be used. For devices that map 49 + * connectors to encoders 1:1, the connector should be attached at 50 + * initialization time with a call to drm_mode_connector_attach_encoder(). The 51 + * driver must also set the struct &drm_connector encoder field to point to the 52 + * attached encoder. 53 + * 54 + * For connectors which are not fixed (like built-in panels) the driver needs to 55 + * support hotplug notifications. The simplest way to do that is by using the 56 + * probe helpers, see drm_kms_helper_poll_init() for connectors which don't have 57 + * hardware support for hotplug interrupts. Connectors with hardware hotplug 58 + * support can instead use e.g. drm_helper_hpd_irq_event(). 59 + */ 60 + 61 + struct drm_conn_prop_enum_list { 62 + int type; 63 + const char *name; 64 + struct ida ida; 65 + }; 66 + 67 + /* 68 + * Connector and encoder types. 69 + */ 70 + static struct drm_conn_prop_enum_list drm_connector_enum_list[] = { 71 + { DRM_MODE_CONNECTOR_Unknown, "Unknown" }, 72 + { DRM_MODE_CONNECTOR_VGA, "VGA" }, 73 + { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, 74 + { DRM_MODE_CONNECTOR_DVID, "DVI-D" }, 75 + { DRM_MODE_CONNECTOR_DVIA, "DVI-A" }, 76 + { DRM_MODE_CONNECTOR_Composite, "Composite" }, 77 + { DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO" }, 78 + { DRM_MODE_CONNECTOR_LVDS, "LVDS" }, 79 + { DRM_MODE_CONNECTOR_Component, "Component" }, 80 + { DRM_MODE_CONNECTOR_9PinDIN, "DIN" }, 81 + { DRM_MODE_CONNECTOR_DisplayPort, "DP" }, 82 + { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" }, 83 + { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" }, 84 + { DRM_MODE_CONNECTOR_TV, "TV" }, 85 + { DRM_MODE_CONNECTOR_eDP, "eDP" }, 86 + { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, 87 + { DRM_MODE_CONNECTOR_DSI, "DSI" }, 88 + { DRM_MODE_CONNECTOR_DPI, "DPI" }, 89 + }; 90 + 91 + void drm_connector_ida_init(void) 92 + { 93 + int i; 94 + 95 + for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) 96 + ida_init(&drm_connector_enum_list[i].ida); 97 + } 98 + 99 + void drm_connector_ida_destroy(void) 100 + { 101 + int i; 102 + 103 + for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) 104 + ida_destroy(&drm_connector_enum_list[i].ida); 105 + } 106 + 107 + /** 108 + * drm_connector_get_cmdline_mode - reads the user's cmdline mode 109 + * @connector: connector to quwery 110 + * 111 + * The kernel supports per-connector configuration of its consoles through 112 + * use of the video= parameter. This function parses that option and 113 + * extracts the user's specified mode (or enable/disable status) for a 114 + * particular connector. This is typically only used during the early fbdev 115 + * setup. 116 + */ 117 + static void drm_connector_get_cmdline_mode(struct drm_connector *connector) 118 + { 119 + struct drm_cmdline_mode *mode = &connector->cmdline_mode; 120 + char *option = NULL; 121 + 122 + if (fb_get_options(connector->name, &option)) 123 + return; 124 + 125 + if (!drm_mode_parse_command_line_for_connector(option, 126 + connector, 127 + mode)) 128 + return; 129 + 130 + if (mode->force) { 131 + const char *s; 132 + 133 + switch (mode->force) { 134 + case DRM_FORCE_OFF: 135 + s = "OFF"; 136 + break; 137 + case DRM_FORCE_ON_DIGITAL: 138 + s = "ON - dig"; 139 + break; 140 + default: 141 + case DRM_FORCE_ON: 142 + s = "ON"; 143 + break; 144 + } 145 + 146 + DRM_INFO("forcing %s connector %s\n", connector->name, s); 147 + connector->force = mode->force; 148 + } 149 + 150 + DRM_DEBUG_KMS("cmdline mode for connector %s %dx%d@%dHz%s%s%s\n", 151 + connector->name, 152 + mode->xres, mode->yres, 153 + mode->refresh_specified ? mode->refresh : 60, 154 + mode->rb ? " reduced blanking" : "", 155 + mode->margins ? " with margins" : "", 156 + mode->interlace ? " interlaced" : ""); 157 + } 158 + 159 + static void drm_connector_free(struct kref *kref) 160 + { 161 + struct drm_connector *connector = 162 + container_of(kref, struct drm_connector, base.refcount); 163 + struct drm_device *dev = connector->dev; 164 + 165 + drm_mode_object_unregister(dev, &connector->base); 166 + connector->funcs->destroy(connector); 167 + } 168 + 169 + /** 170 + * drm_connector_init - Init a preallocated connector 171 + * @dev: DRM device 172 + * @connector: the connector to init 173 + * @funcs: callbacks for this connector 174 + * @connector_type: user visible type of the connector 175 + * 176 + * Initialises a preallocated connector. Connectors should be 177 + * subclassed as part of driver connector objects. 178 + * 179 + * Returns: 180 + * Zero on success, error code on failure. 181 + */ 182 + int drm_connector_init(struct drm_device *dev, 183 + struct drm_connector *connector, 184 + const struct drm_connector_funcs *funcs, 185 + int connector_type) 186 + { 187 + struct drm_mode_config *config = &dev->mode_config; 188 + int ret; 189 + struct ida *connector_ida = 190 + &drm_connector_enum_list[connector_type].ida; 191 + 192 + drm_modeset_lock_all(dev); 193 + 194 + ret = drm_mode_object_get_reg(dev, &connector->base, 195 + DRM_MODE_OBJECT_CONNECTOR, 196 + false, drm_connector_free); 197 + if (ret) 198 + goto out_unlock; 199 + 200 + connector->base.properties = &connector->properties; 201 + connector->dev = dev; 202 + connector->funcs = funcs; 203 + 204 + ret = ida_simple_get(&config->connector_ida, 0, 0, GFP_KERNEL); 205 + if (ret < 0) 206 + goto out_put; 207 + connector->index = ret; 208 + ret = 0; 209 + 210 + connector->connector_type = connector_type; 211 + connector->connector_type_id = 212 + ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); 213 + if (connector->connector_type_id < 0) { 214 + ret = connector->connector_type_id; 215 + goto out_put_id; 216 + } 217 + connector->name = 218 + kasprintf(GFP_KERNEL, "%s-%d", 219 + drm_connector_enum_list[connector_type].name, 220 + connector->connector_type_id); 221 + if (!connector->name) { 222 + ret = -ENOMEM; 223 + goto out_put_type_id; 224 + } 225 + 226 + INIT_LIST_HEAD(&connector->probed_modes); 227 + INIT_LIST_HEAD(&connector->modes); 228 + connector->edid_blob_ptr = NULL; 229 + connector->status = connector_status_unknown; 230 + 231 + drm_connector_get_cmdline_mode(connector); 232 + 233 + /* We should add connectors at the end to avoid upsetting the connector 234 + * index too much. */ 235 + list_add_tail(&connector->head, &config->connector_list); 236 + config->num_connector++; 237 + 238 + if (connector_type != DRM_MODE_CONNECTOR_VIRTUAL) 239 + drm_object_attach_property(&connector->base, 240 + config->edid_property, 241 + 0); 242 + 243 + drm_object_attach_property(&connector->base, 244 + config->dpms_property, 0); 245 + 246 + if (drm_core_check_feature(dev, DRIVER_ATOMIC)) { 247 + drm_object_attach_property(&connector->base, config->prop_crtc_id, 0); 248 + } 249 + 250 + connector->debugfs_entry = NULL; 251 + out_put_type_id: 252 + if (ret) 253 + ida_remove(connector_ida, connector->connector_type_id); 254 + out_put_id: 255 + if (ret) 256 + ida_remove(&config->connector_ida, connector->index); 257 + out_put: 258 + if (ret) 259 + drm_mode_object_unregister(dev, &connector->base); 260 + 261 + out_unlock: 262 + drm_modeset_unlock_all(dev); 263 + 264 + return ret; 265 + } 266 + EXPORT_SYMBOL(drm_connector_init); 267 + 268 + /** 269 + * drm_mode_connector_attach_encoder - attach a connector to an encoder 270 + * @connector: connector to attach 271 + * @encoder: encoder to attach @connector to 272 + * 273 + * This function links up a connector to an encoder. Note that the routing 274 + * restrictions between encoders and crtcs are exposed to userspace through the 275 + * possible_clones and possible_crtcs bitmasks. 276 + * 277 + * Returns: 278 + * Zero on success, negative errno on failure. 279 + */ 280 + int drm_mode_connector_attach_encoder(struct drm_connector *connector, 281 + struct drm_encoder *encoder) 282 + { 283 + int i; 284 + 285 + /* 286 + * In the past, drivers have attempted to model the static association 287 + * of connector to encoder in simple connector/encoder devices using a 288 + * direct assignment of connector->encoder = encoder. This connection 289 + * is a logical one and the responsibility of the core, so drivers are 290 + * expected not to mess with this. 291 + * 292 + * Note that the error return should've been enough here, but a large 293 + * majority of drivers ignores the return value, so add in a big WARN 294 + * to get people's attention. 295 + */ 296 + if (WARN_ON(connector->encoder)) 297 + return -EINVAL; 298 + 299 + for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 300 + if (connector->encoder_ids[i] == 0) { 301 + connector->encoder_ids[i] = encoder->base.id; 302 + return 0; 303 + } 304 + } 305 + return -ENOMEM; 306 + } 307 + EXPORT_SYMBOL(drm_mode_connector_attach_encoder); 308 + 309 + static void drm_mode_remove(struct drm_connector *connector, 310 + struct drm_display_mode *mode) 311 + { 312 + list_del(&mode->head); 313 + drm_mode_destroy(connector->dev, mode); 314 + } 315 + 316 + /** 317 + * drm_connector_cleanup - cleans up an initialised connector 318 + * @connector: connector to cleanup 319 + * 320 + * Cleans up the connector but doesn't free the object. 321 + */ 322 + void drm_connector_cleanup(struct drm_connector *connector) 323 + { 324 + struct drm_device *dev = connector->dev; 325 + struct drm_display_mode *mode, *t; 326 + 327 + /* The connector should have been removed from userspace long before 328 + * it is finally destroyed. 329 + */ 330 + if (WARN_ON(connector->registered)) 331 + drm_connector_unregister(connector); 332 + 333 + if (connector->tile_group) { 334 + drm_mode_put_tile_group(dev, connector->tile_group); 335 + connector->tile_group = NULL; 336 + } 337 + 338 + list_for_each_entry_safe(mode, t, &connector->probed_modes, head) 339 + drm_mode_remove(connector, mode); 340 + 341 + list_for_each_entry_safe(mode, t, &connector->modes, head) 342 + drm_mode_remove(connector, mode); 343 + 344 + ida_remove(&drm_connector_enum_list[connector->connector_type].ida, 345 + connector->connector_type_id); 346 + 347 + ida_remove(&dev->mode_config.connector_ida, 348 + connector->index); 349 + 350 + kfree(connector->display_info.bus_formats); 351 + drm_mode_object_unregister(dev, &connector->base); 352 + kfree(connector->name); 353 + connector->name = NULL; 354 + list_del(&connector->head); 355 + dev->mode_config.num_connector--; 356 + 357 + WARN_ON(connector->state && !connector->funcs->atomic_destroy_state); 358 + if (connector->state && connector->funcs->atomic_destroy_state) 359 + connector->funcs->atomic_destroy_state(connector, 360 + connector->state); 361 + 362 + memset(connector, 0, sizeof(*connector)); 363 + } 364 + EXPORT_SYMBOL(drm_connector_cleanup); 365 + 366 + /** 367 + * drm_connector_register - register a connector 368 + * @connector: the connector to register 369 + * 370 + * Register userspace interfaces for a connector 371 + * 372 + * Returns: 373 + * Zero on success, error code on failure. 374 + */ 375 + int drm_connector_register(struct drm_connector *connector) 376 + { 377 + int ret; 378 + 379 + if (connector->registered) 380 + return 0; 381 + 382 + ret = drm_sysfs_connector_add(connector); 383 + if (ret) 384 + return ret; 385 + 386 + ret = drm_debugfs_connector_add(connector); 387 + if (ret) { 388 + goto err_sysfs; 389 + } 390 + 391 + if (connector->funcs->late_register) { 392 + ret = connector->funcs->late_register(connector); 393 + if (ret) 394 + goto err_debugfs; 395 + } 396 + 397 + drm_mode_object_register(connector->dev, &connector->base); 398 + 399 + connector->registered = true; 400 + return 0; 401 + 402 + err_debugfs: 403 + drm_debugfs_connector_remove(connector); 404 + err_sysfs: 405 + drm_sysfs_connector_remove(connector); 406 + return ret; 407 + } 408 + EXPORT_SYMBOL(drm_connector_register); 409 + 410 + /** 411 + * drm_connector_unregister - unregister a connector 412 + * @connector: the connector to unregister 413 + * 414 + * Unregister userspace interfaces for a connector 415 + */ 416 + void drm_connector_unregister(struct drm_connector *connector) 417 + { 418 + if (!connector->registered) 419 + return; 420 + 421 + if (connector->funcs->early_unregister) 422 + connector->funcs->early_unregister(connector); 423 + 424 + drm_sysfs_connector_remove(connector); 425 + drm_debugfs_connector_remove(connector); 426 + 427 + connector->registered = false; 428 + } 429 + EXPORT_SYMBOL(drm_connector_unregister); 430 + 431 + void drm_connector_unregister_all(struct drm_device *dev) 432 + { 433 + struct drm_connector *connector; 434 + 435 + /* FIXME: taking the mode config mutex ends up in a clash with sysfs */ 436 + list_for_each_entry(connector, &dev->mode_config.connector_list, head) 437 + drm_connector_unregister(connector); 438 + } 439 + 440 + int drm_connector_register_all(struct drm_device *dev) 441 + { 442 + struct drm_connector *connector; 443 + int ret; 444 + 445 + /* FIXME: taking the mode config mutex ends up in a clash with 446 + * fbcon/backlight registration */ 447 + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 448 + ret = drm_connector_register(connector); 449 + if (ret) 450 + goto err; 451 + } 452 + 453 + return 0; 454 + 455 + err: 456 + mutex_unlock(&dev->mode_config.mutex); 457 + drm_connector_unregister_all(dev); 458 + return ret; 459 + } 460 + 461 + /** 462 + * drm_get_connector_status_name - return a string for connector status 463 + * @status: connector status to compute name of 464 + * 465 + * In contrast to the other drm_get_*_name functions this one here returns a 466 + * const pointer and hence is threadsafe. 467 + */ 468 + const char *drm_get_connector_status_name(enum drm_connector_status status) 469 + { 470 + if (status == connector_status_connected) 471 + return "connected"; 472 + else if (status == connector_status_disconnected) 473 + return "disconnected"; 474 + else 475 + return "unknown"; 476 + } 477 + EXPORT_SYMBOL(drm_get_connector_status_name); 478 + 479 + static const struct drm_prop_enum_list drm_subpixel_enum_list[] = { 480 + { SubPixelUnknown, "Unknown" }, 481 + { SubPixelHorizontalRGB, "Horizontal RGB" }, 482 + { SubPixelHorizontalBGR, "Horizontal BGR" }, 483 + { SubPixelVerticalRGB, "Vertical RGB" }, 484 + { SubPixelVerticalBGR, "Vertical BGR" }, 485 + { SubPixelNone, "None" }, 486 + }; 487 + 488 + /** 489 + * drm_get_subpixel_order_name - return a string for a given subpixel enum 490 + * @order: enum of subpixel_order 491 + * 492 + * Note you could abuse this and return something out of bounds, but that 493 + * would be a caller error. No unscrubbed user data should make it here. 494 + */ 495 + const char *drm_get_subpixel_order_name(enum subpixel_order order) 496 + { 497 + return drm_subpixel_enum_list[order].name; 498 + } 499 + EXPORT_SYMBOL(drm_get_subpixel_order_name); 500 + 501 + static const struct drm_prop_enum_list drm_dpms_enum_list[] = { 502 + { DRM_MODE_DPMS_ON, "On" }, 503 + { DRM_MODE_DPMS_STANDBY, "Standby" }, 504 + { DRM_MODE_DPMS_SUSPEND, "Suspend" }, 505 + { DRM_MODE_DPMS_OFF, "Off" } 506 + }; 507 + DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list) 508 + 509 + /** 510 + * drm_display_info_set_bus_formats - set the supported bus formats 511 + * @info: display info to store bus formats in 512 + * @formats: array containing the supported bus formats 513 + * @num_formats: the number of entries in the fmts array 514 + * 515 + * Store the supported bus formats in display info structure. 516 + * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for 517 + * a full list of available formats. 518 + */ 519 + int drm_display_info_set_bus_formats(struct drm_display_info *info, 520 + const u32 *formats, 521 + unsigned int num_formats) 522 + { 523 + u32 *fmts = NULL; 524 + 525 + if (!formats && num_formats) 526 + return -EINVAL; 527 + 528 + if (formats && num_formats) { 529 + fmts = kmemdup(formats, sizeof(*formats) * num_formats, 530 + GFP_KERNEL); 531 + if (!fmts) 532 + return -ENOMEM; 533 + } 534 + 535 + kfree(info->bus_formats); 536 + info->bus_formats = fmts; 537 + info->num_bus_formats = num_formats; 538 + 539 + return 0; 540 + } 541 + EXPORT_SYMBOL(drm_display_info_set_bus_formats); 542 + 543 + /* Optional connector properties. */ 544 + static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = { 545 + { DRM_MODE_SCALE_NONE, "None" }, 546 + { DRM_MODE_SCALE_FULLSCREEN, "Full" }, 547 + { DRM_MODE_SCALE_CENTER, "Center" }, 548 + { DRM_MODE_SCALE_ASPECT, "Full aspect" }, 549 + }; 550 + 551 + static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = { 552 + { DRM_MODE_PICTURE_ASPECT_NONE, "Automatic" }, 553 + { DRM_MODE_PICTURE_ASPECT_4_3, "4:3" }, 554 + { DRM_MODE_PICTURE_ASPECT_16_9, "16:9" }, 555 + }; 556 + 557 + static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = { 558 + { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */ 559 + { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */ 560 + { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" }, /* DVI-I */ 561 + }; 562 + DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list) 563 + 564 + static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = { 565 + { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" }, /* DVI-I and TV-out */ 566 + { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */ 567 + { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" }, /* DVI-I */ 568 + }; 569 + DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name, 570 + drm_dvi_i_subconnector_enum_list) 571 + 572 + static const struct drm_prop_enum_list drm_tv_select_enum_list[] = { 573 + { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */ 574 + { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */ 575 + { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" }, /* TV-out */ 576 + { DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */ 577 + { DRM_MODE_SUBCONNECTOR_SCART, "SCART" }, /* TV-out */ 578 + }; 579 + DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list) 580 + 581 + static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = { 582 + { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" }, /* DVI-I and TV-out */ 583 + { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */ 584 + { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" }, /* TV-out */ 585 + { DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */ 586 + { DRM_MODE_SUBCONNECTOR_SCART, "SCART" }, /* TV-out */ 587 + }; 588 + DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name, 589 + drm_tv_subconnector_enum_list) 590 + 591 + int drm_connector_create_standard_properties(struct drm_device *dev) 592 + { 593 + struct drm_property *prop; 594 + 595 + prop = drm_property_create(dev, DRM_MODE_PROP_BLOB | 596 + DRM_MODE_PROP_IMMUTABLE, 597 + "EDID", 0); 598 + if (!prop) 599 + return -ENOMEM; 600 + dev->mode_config.edid_property = prop; 601 + 602 + prop = drm_property_create_enum(dev, 0, 603 + "DPMS", drm_dpms_enum_list, 604 + ARRAY_SIZE(drm_dpms_enum_list)); 605 + if (!prop) 606 + return -ENOMEM; 607 + dev->mode_config.dpms_property = prop; 608 + 609 + prop = drm_property_create(dev, 610 + DRM_MODE_PROP_BLOB | 611 + DRM_MODE_PROP_IMMUTABLE, 612 + "PATH", 0); 613 + if (!prop) 614 + return -ENOMEM; 615 + dev->mode_config.path_property = prop; 616 + 617 + prop = drm_property_create(dev, 618 + DRM_MODE_PROP_BLOB | 619 + DRM_MODE_PROP_IMMUTABLE, 620 + "TILE", 0); 621 + if (!prop) 622 + return -ENOMEM; 623 + dev->mode_config.tile_property = prop; 624 + 625 + return 0; 626 + } 627 + 628 + /** 629 + * drm_mode_create_dvi_i_properties - create DVI-I specific connector properties 630 + * @dev: DRM device 631 + * 632 + * Called by a driver the first time a DVI-I connector is made. 633 + */ 634 + int drm_mode_create_dvi_i_properties(struct drm_device *dev) 635 + { 636 + struct drm_property *dvi_i_selector; 637 + struct drm_property *dvi_i_subconnector; 638 + 639 + if (dev->mode_config.dvi_i_select_subconnector_property) 640 + return 0; 641 + 642 + dvi_i_selector = 643 + drm_property_create_enum(dev, 0, 644 + "select subconnector", 645 + drm_dvi_i_select_enum_list, 646 + ARRAY_SIZE(drm_dvi_i_select_enum_list)); 647 + dev->mode_config.dvi_i_select_subconnector_property = dvi_i_selector; 648 + 649 + dvi_i_subconnector = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, 650 + "subconnector", 651 + drm_dvi_i_subconnector_enum_list, 652 + ARRAY_SIZE(drm_dvi_i_subconnector_enum_list)); 653 + dev->mode_config.dvi_i_subconnector_property = dvi_i_subconnector; 654 + 655 + return 0; 656 + } 657 + EXPORT_SYMBOL(drm_mode_create_dvi_i_properties); 658 + 659 + /** 660 + * drm_create_tv_properties - create TV specific connector properties 661 + * @dev: DRM device 662 + * @num_modes: number of different TV formats (modes) supported 663 + * @modes: array of pointers to strings containing name of each format 664 + * 665 + * Called by a driver's TV initialization routine, this function creates 666 + * the TV specific connector properties for a given device. Caller is 667 + * responsible for allocating a list of format names and passing them to 668 + * this routine. 669 + */ 670 + int drm_mode_create_tv_properties(struct drm_device *dev, 671 + unsigned int num_modes, 672 + const char * const modes[]) 673 + { 674 + struct drm_property *tv_selector; 675 + struct drm_property *tv_subconnector; 676 + unsigned int i; 677 + 678 + if (dev->mode_config.tv_select_subconnector_property) 679 + return 0; 680 + 681 + /* 682 + * Basic connector properties 683 + */ 684 + tv_selector = drm_property_create_enum(dev, 0, 685 + "select subconnector", 686 + drm_tv_select_enum_list, 687 + ARRAY_SIZE(drm_tv_select_enum_list)); 688 + if (!tv_selector) 689 + goto nomem; 690 + 691 + dev->mode_config.tv_select_subconnector_property = tv_selector; 692 + 693 + tv_subconnector = 694 + drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, 695 + "subconnector", 696 + drm_tv_subconnector_enum_list, 697 + ARRAY_SIZE(drm_tv_subconnector_enum_list)); 698 + if (!tv_subconnector) 699 + goto nomem; 700 + dev->mode_config.tv_subconnector_property = tv_subconnector; 701 + 702 + /* 703 + * Other, TV specific properties: margins & TV modes. 704 + */ 705 + dev->mode_config.tv_left_margin_property = 706 + drm_property_create_range(dev, 0, "left margin", 0, 100); 707 + if (!dev->mode_config.tv_left_margin_property) 708 + goto nomem; 709 + 710 + dev->mode_config.tv_right_margin_property = 711 + drm_property_create_range(dev, 0, "right margin", 0, 100); 712 + if (!dev->mode_config.tv_right_margin_property) 713 + goto nomem; 714 + 715 + dev->mode_config.tv_top_margin_property = 716 + drm_property_create_range(dev, 0, "top margin", 0, 100); 717 + if (!dev->mode_config.tv_top_margin_property) 718 + goto nomem; 719 + 720 + dev->mode_config.tv_bottom_margin_property = 721 + drm_property_create_range(dev, 0, "bottom margin", 0, 100); 722 + if (!dev->mode_config.tv_bottom_margin_property) 723 + goto nomem; 724 + 725 + dev->mode_config.tv_mode_property = 726 + drm_property_create(dev, DRM_MODE_PROP_ENUM, 727 + "mode", num_modes); 728 + if (!dev->mode_config.tv_mode_property) 729 + goto nomem; 730 + 731 + for (i = 0; i < num_modes; i++) 732 + drm_property_add_enum(dev->mode_config.tv_mode_property, i, 733 + i, modes[i]); 734 + 735 + dev->mode_config.tv_brightness_property = 736 + drm_property_create_range(dev, 0, "brightness", 0, 100); 737 + if (!dev->mode_config.tv_brightness_property) 738 + goto nomem; 739 + 740 + dev->mode_config.tv_contrast_property = 741 + drm_property_create_range(dev, 0, "contrast", 0, 100); 742 + if (!dev->mode_config.tv_contrast_property) 743 + goto nomem; 744 + 745 + dev->mode_config.tv_flicker_reduction_property = 746 + drm_property_create_range(dev, 0, "flicker reduction", 0, 100); 747 + if (!dev->mode_config.tv_flicker_reduction_property) 748 + goto nomem; 749 + 750 + dev->mode_config.tv_overscan_property = 751 + drm_property_create_range(dev, 0, "overscan", 0, 100); 752 + if (!dev->mode_config.tv_overscan_property) 753 + goto nomem; 754 + 755 + dev->mode_config.tv_saturation_property = 756 + drm_property_create_range(dev, 0, "saturation", 0, 100); 757 + if (!dev->mode_config.tv_saturation_property) 758 + goto nomem; 759 + 760 + dev->mode_config.tv_hue_property = 761 + drm_property_create_range(dev, 0, "hue", 0, 100); 762 + if (!dev->mode_config.tv_hue_property) 763 + goto nomem; 764 + 765 + return 0; 766 + nomem: 767 + return -ENOMEM; 768 + } 769 + EXPORT_SYMBOL(drm_mode_create_tv_properties); 770 + 771 + /** 772 + * drm_mode_create_scaling_mode_property - create scaling mode property 773 + * @dev: DRM device 774 + * 775 + * Called by a driver the first time it's needed, must be attached to desired 776 + * connectors. 777 + */ 778 + int drm_mode_create_scaling_mode_property(struct drm_device *dev) 779 + { 780 + struct drm_property *scaling_mode; 781 + 782 + if (dev->mode_config.scaling_mode_property) 783 + return 0; 784 + 785 + scaling_mode = 786 + drm_property_create_enum(dev, 0, "scaling mode", 787 + drm_scaling_mode_enum_list, 788 + ARRAY_SIZE(drm_scaling_mode_enum_list)); 789 + 790 + dev->mode_config.scaling_mode_property = scaling_mode; 791 + 792 + return 0; 793 + } 794 + EXPORT_SYMBOL(drm_mode_create_scaling_mode_property); 795 + 796 + /** 797 + * drm_mode_create_aspect_ratio_property - create aspect ratio property 798 + * @dev: DRM device 799 + * 800 + * Called by a driver the first time it's needed, must be attached to desired 801 + * connectors. 802 + * 803 + * Returns: 804 + * Zero on success, negative errno on failure. 805 + */ 806 + int drm_mode_create_aspect_ratio_property(struct drm_device *dev) 807 + { 808 + if (dev->mode_config.aspect_ratio_property) 809 + return 0; 810 + 811 + dev->mode_config.aspect_ratio_property = 812 + drm_property_create_enum(dev, 0, "aspect ratio", 813 + drm_aspect_ratio_enum_list, 814 + ARRAY_SIZE(drm_aspect_ratio_enum_list)); 815 + 816 + if (dev->mode_config.aspect_ratio_property == NULL) 817 + return -ENOMEM; 818 + 819 + return 0; 820 + } 821 + EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property); 822 + 823 + /** 824 + * drm_mode_create_suggested_offset_properties - create suggests offset properties 825 + * @dev: DRM device 826 + * 827 + * Create the the suggested x/y offset property for connectors. 828 + */ 829 + int drm_mode_create_suggested_offset_properties(struct drm_device *dev) 830 + { 831 + if (dev->mode_config.suggested_x_property && dev->mode_config.suggested_y_property) 832 + return 0; 833 + 834 + dev->mode_config.suggested_x_property = 835 + drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, "suggested X", 0, 0xffffffff); 836 + 837 + dev->mode_config.suggested_y_property = 838 + drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, "suggested Y", 0, 0xffffffff); 839 + 840 + if (dev->mode_config.suggested_x_property == NULL || 841 + dev->mode_config.suggested_y_property == NULL) 842 + return -ENOMEM; 843 + return 0; 844 + } 845 + EXPORT_SYMBOL(drm_mode_create_suggested_offset_properties); 846 + 847 + /** 848 + * drm_mode_connector_set_path_property - set tile property on connector 849 + * @connector: connector to set property on. 850 + * @path: path to use for property; must not be NULL. 851 + * 852 + * This creates a property to expose to userspace to specify a 853 + * connector path. This is mainly used for DisplayPort MST where 854 + * connectors have a topology and we want to allow userspace to give 855 + * them more meaningful names. 856 + * 857 + * Returns: 858 + * Zero on success, negative errno on failure. 859 + */ 860 + int drm_mode_connector_set_path_property(struct drm_connector *connector, 861 + const char *path) 862 + { 863 + struct drm_device *dev = connector->dev; 864 + int ret; 865 + 866 + ret = drm_property_replace_global_blob(dev, 867 + &connector->path_blob_ptr, 868 + strlen(path) + 1, 869 + path, 870 + &connector->base, 871 + dev->mode_config.path_property); 872 + return ret; 873 + } 874 + EXPORT_SYMBOL(drm_mode_connector_set_path_property); 875 + 876 + /** 877 + * drm_mode_connector_set_tile_property - set tile property on connector 878 + * @connector: connector to set property on. 879 + * 880 + * This looks up the tile information for a connector, and creates a 881 + * property for userspace to parse if it exists. The property is of 882 + * the form of 8 integers using ':' as a separator. 883 + * 884 + * Returns: 885 + * Zero on success, errno on failure. 886 + */ 887 + int drm_mode_connector_set_tile_property(struct drm_connector *connector) 888 + { 889 + struct drm_device *dev = connector->dev; 890 + char tile[256]; 891 + int ret; 892 + 893 + if (!connector->has_tile) { 894 + ret = drm_property_replace_global_blob(dev, 895 + &connector->tile_blob_ptr, 896 + 0, 897 + NULL, 898 + &connector->base, 899 + dev->mode_config.tile_property); 900 + return ret; 901 + } 902 + 903 + snprintf(tile, 256, "%d:%d:%d:%d:%d:%d:%d:%d", 904 + connector->tile_group->id, connector->tile_is_single_monitor, 905 + connector->num_h_tile, connector->num_v_tile, 906 + connector->tile_h_loc, connector->tile_v_loc, 907 + connector->tile_h_size, connector->tile_v_size); 908 + 909 + ret = drm_property_replace_global_blob(dev, 910 + &connector->tile_blob_ptr, 911 + strlen(tile) + 1, 912 + tile, 913 + &connector->base, 914 + dev->mode_config.tile_property); 915 + return ret; 916 + } 917 + EXPORT_SYMBOL(drm_mode_connector_set_tile_property); 918 + 919 + /** 920 + * drm_mode_connector_update_edid_property - update the edid property of a connector 921 + * @connector: drm connector 922 + * @edid: new value of the edid property 923 + * 924 + * This function creates a new blob modeset object and assigns its id to the 925 + * connector's edid property. 926 + * 927 + * Returns: 928 + * Zero on success, negative errno on failure. 929 + */ 930 + int drm_mode_connector_update_edid_property(struct drm_connector *connector, 931 + const struct edid *edid) 932 + { 933 + struct drm_device *dev = connector->dev; 934 + size_t size = 0; 935 + int ret; 936 + 937 + /* ignore requests to set edid when overridden */ 938 + if (connector->override_edid) 939 + return 0; 940 + 941 + if (edid) 942 + size = EDID_LENGTH * (1 + edid->extensions); 943 + 944 + ret = drm_property_replace_global_blob(dev, 945 + &connector->edid_blob_ptr, 946 + size, 947 + edid, 948 + &connector->base, 949 + dev->mode_config.edid_property); 950 + return ret; 951 + } 952 + EXPORT_SYMBOL(drm_mode_connector_update_edid_property); 953 + 954 + int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj, 955 + struct drm_property *property, 956 + uint64_t value) 957 + { 958 + int ret = -EINVAL; 959 + struct drm_connector *connector = obj_to_connector(obj); 960 + 961 + /* Do DPMS ourselves */ 962 + if (property == connector->dev->mode_config.dpms_property) { 963 + ret = (*connector->funcs->dpms)(connector, (int)value); 964 + } else if (connector->funcs->set_property) 965 + ret = connector->funcs->set_property(connector, property, value); 966 + 967 + /* store the property value if successful */ 968 + if (!ret) 969 + drm_object_property_set_value(&connector->base, property, value); 970 + return ret; 971 + } 972 + 973 + int drm_mode_connector_property_set_ioctl(struct drm_device *dev, 974 + void *data, struct drm_file *file_priv) 975 + { 976 + struct drm_mode_connector_set_property *conn_set_prop = data; 977 + struct drm_mode_obj_set_property obj_set_prop = { 978 + .value = conn_set_prop->value, 979 + .prop_id = conn_set_prop->prop_id, 980 + .obj_id = conn_set_prop->connector_id, 981 + .obj_type = DRM_MODE_OBJECT_CONNECTOR 982 + }; 983 + 984 + /* It does all the locking and checking we need */ 985 + return drm_mode_obj_set_property_ioctl(dev, &obj_set_prop, file_priv); 986 + } 987 + 988 + static struct drm_encoder *drm_connector_get_encoder(struct drm_connector *connector) 989 + { 990 + /* For atomic drivers only state objects are synchronously updated and 991 + * protected by modeset locks, so check those first. */ 992 + if (connector->state) 993 + return connector->state->best_encoder; 994 + return connector->encoder; 995 + } 996 + 997 + static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode, 998 + const struct drm_file *file_priv) 999 + { 1000 + /* 1001 + * If user-space hasn't configured the driver to expose the stereo 3D 1002 + * modes, don't expose them. 1003 + */ 1004 + if (!file_priv->stereo_allowed && drm_mode_is_stereo(mode)) 1005 + return false; 1006 + 1007 + return true; 1008 + } 1009 + 1010 + int drm_mode_getconnector(struct drm_device *dev, void *data, 1011 + struct drm_file *file_priv) 1012 + { 1013 + struct drm_mode_get_connector *out_resp = data; 1014 + struct drm_connector *connector; 1015 + struct drm_encoder *encoder; 1016 + struct drm_display_mode *mode; 1017 + int mode_count = 0; 1018 + int encoders_count = 0; 1019 + int ret = 0; 1020 + int copied = 0; 1021 + int i; 1022 + struct drm_mode_modeinfo u_mode; 1023 + struct drm_mode_modeinfo __user *mode_ptr; 1024 + uint32_t __user *encoder_ptr; 1025 + 1026 + if (!drm_core_check_feature(dev, DRIVER_MODESET)) 1027 + return -EINVAL; 1028 + 1029 + memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); 1030 + 1031 + mutex_lock(&dev->mode_config.mutex); 1032 + 1033 + connector = drm_connector_lookup(dev, out_resp->connector_id); 1034 + if (!connector) { 1035 + ret = -ENOENT; 1036 + goto out_unlock; 1037 + } 1038 + 1039 + for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) 1040 + if (connector->encoder_ids[i] != 0) 1041 + encoders_count++; 1042 + 1043 + if (out_resp->count_modes == 0) { 1044 + connector->funcs->fill_modes(connector, 1045 + dev->mode_config.max_width, 1046 + dev->mode_config.max_height); 1047 + } 1048 + 1049 + /* delayed so we get modes regardless of pre-fill_modes state */ 1050 + list_for_each_entry(mode, &connector->modes, head) 1051 + if (drm_mode_expose_to_userspace(mode, file_priv)) 1052 + mode_count++; 1053 + 1054 + out_resp->connector_id = connector->base.id; 1055 + out_resp->connector_type = connector->connector_type; 1056 + out_resp->connector_type_id = connector->connector_type_id; 1057 + out_resp->mm_width = connector->display_info.width_mm; 1058 + out_resp->mm_height = connector->display_info.height_mm; 1059 + out_resp->subpixel = connector->display_info.subpixel_order; 1060 + out_resp->connection = connector->status; 1061 + 1062 + drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); 1063 + encoder = drm_connector_get_encoder(connector); 1064 + if (encoder) 1065 + out_resp->encoder_id = encoder->base.id; 1066 + else 1067 + out_resp->encoder_id = 0; 1068 + 1069 + /* 1070 + * This ioctl is called twice, once to determine how much space is 1071 + * needed, and the 2nd time to fill it. 1072 + */ 1073 + if ((out_resp->count_modes >= mode_count) && mode_count) { 1074 + copied = 0; 1075 + mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long)out_resp->modes_ptr; 1076 + list_for_each_entry(mode, &connector->modes, head) { 1077 + if (!drm_mode_expose_to_userspace(mode, file_priv)) 1078 + continue; 1079 + 1080 + drm_mode_convert_to_umode(&u_mode, mode); 1081 + if (copy_to_user(mode_ptr + copied, 1082 + &u_mode, sizeof(u_mode))) { 1083 + ret = -EFAULT; 1084 + goto out; 1085 + } 1086 + copied++; 1087 + } 1088 + } 1089 + out_resp->count_modes = mode_count; 1090 + 1091 + ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic, 1092 + (uint32_t __user *)(unsigned long)(out_resp->props_ptr), 1093 + (uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr), 1094 + &out_resp->count_props); 1095 + if (ret) 1096 + goto out; 1097 + 1098 + if ((out_resp->count_encoders >= encoders_count) && encoders_count) { 1099 + copied = 0; 1100 + encoder_ptr = (uint32_t __user *)(unsigned long)(out_resp->encoders_ptr); 1101 + for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1102 + if (connector->encoder_ids[i] != 0) { 1103 + if (put_user(connector->encoder_ids[i], 1104 + encoder_ptr + copied)) { 1105 + ret = -EFAULT; 1106 + goto out; 1107 + } 1108 + copied++; 1109 + } 1110 + } 1111 + } 1112 + out_resp->count_encoders = encoders_count; 1113 + 1114 + out: 1115 + drm_modeset_unlock(&dev->mode_config.connection_mutex); 1116 + 1117 + drm_connector_unreference(connector); 1118 + out_unlock: 1119 + mutex_unlock(&dev->mode_config.mutex); 1120 + 1121 + return ret; 1122 + } 1123 +
+41 -1959
drivers/gpu/drm/drm_crtc.c
··· 40 40 #include <drm/drm_modeset_lock.h> 41 41 #include <drm/drm_atomic.h> 42 42 #include <drm/drm_auth.h> 43 + #include <drm/drm_framebuffer.h> 43 44 44 45 #include "drm_crtc_internal.h" 45 46 #include "drm_internal.h" 46 47 47 - static struct drm_framebuffer * 48 - internal_framebuffer_create(struct drm_device *dev, 49 - const struct drm_mode_fb_cmd2 *r, 50 - struct drm_file *file_priv); 51 - 52 - /* Avoid boilerplate. I'm tired of typing. */ 53 - #define DRM_ENUM_NAME_FN(fnname, list) \ 54 - const char *fnname(int val) \ 55 - { \ 56 - int i; \ 57 - for (i = 0; i < ARRAY_SIZE(list); i++) { \ 58 - if (list[i].type == val) \ 59 - return list[i].name; \ 60 - } \ 61 - return "(unknown)"; \ 62 - } 63 - 64 48 /* 65 49 * Global properties 66 50 */ 67 - static const struct drm_prop_enum_list drm_dpms_enum_list[] = { 68 - { DRM_MODE_DPMS_ON, "On" }, 69 - { DRM_MODE_DPMS_STANDBY, "Standby" }, 70 - { DRM_MODE_DPMS_SUSPEND, "Suspend" }, 71 - { DRM_MODE_DPMS_OFF, "Off" } 72 - }; 73 - 74 - DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list) 75 - 76 51 static const struct drm_prop_enum_list drm_plane_type_enum_list[] = { 77 52 { DRM_PLANE_TYPE_OVERLAY, "Overlay" }, 78 53 { DRM_PLANE_TYPE_PRIMARY, "Primary" }, 79 54 { DRM_PLANE_TYPE_CURSOR, "Cursor" }, 80 - }; 81 - 82 - /* 83 - * Optional properties 84 - */ 85 - static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = { 86 - { DRM_MODE_SCALE_NONE, "None" }, 87 - { DRM_MODE_SCALE_FULLSCREEN, "Full" }, 88 - { DRM_MODE_SCALE_CENTER, "Center" }, 89 - { DRM_MODE_SCALE_ASPECT, "Full aspect" }, 90 - }; 91 - 92 - static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = { 93 - { DRM_MODE_PICTURE_ASPECT_NONE, "Automatic" }, 94 - { DRM_MODE_PICTURE_ASPECT_4_3, "4:3" }, 95 - { DRM_MODE_PICTURE_ASPECT_16_9, "16:9" }, 96 - }; 97 - 98 - /* 99 - * Non-global properties, but "required" for certain connectors. 100 - */ 101 - static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = { 102 - { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */ 103 - { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */ 104 - { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" }, /* DVI-I */ 105 - }; 106 - 107 - DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list) 108 - 109 - static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = { 110 - { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" }, /* DVI-I and TV-out */ 111 - { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */ 112 - { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" }, /* DVI-I */ 113 - }; 114 - 115 - DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name, 116 - drm_dvi_i_subconnector_enum_list) 117 - 118 - static const struct drm_prop_enum_list drm_tv_select_enum_list[] = { 119 - { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */ 120 - { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */ 121 - { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" }, /* TV-out */ 122 - { DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */ 123 - { DRM_MODE_SUBCONNECTOR_SCART, "SCART" }, /* TV-out */ 124 - }; 125 - 126 - DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list) 127 - 128 - static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = { 129 - { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" }, /* DVI-I and TV-out */ 130 - { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */ 131 - { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" }, /* TV-out */ 132 - { DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */ 133 - { DRM_MODE_SUBCONNECTOR_SCART, "SCART" }, /* TV-out */ 134 - }; 135 - 136 - DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name, 137 - drm_tv_subconnector_enum_list) 138 - 139 - static const struct drm_prop_enum_list drm_dirty_info_enum_list[] = { 140 - { DRM_MODE_DIRTY_OFF, "Off" }, 141 - { DRM_MODE_DIRTY_ON, "On" }, 142 - { DRM_MODE_DIRTY_ANNOTATE, "Annotate" }, 143 - }; 144 - 145 - struct drm_conn_prop_enum_list { 146 - int type; 147 - const char *name; 148 - struct ida ida; 149 - }; 150 - 151 - /* 152 - * Connector and encoder types. 153 - */ 154 - static struct drm_conn_prop_enum_list drm_connector_enum_list[] = { 155 - { DRM_MODE_CONNECTOR_Unknown, "Unknown" }, 156 - { DRM_MODE_CONNECTOR_VGA, "VGA" }, 157 - { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, 158 - { DRM_MODE_CONNECTOR_DVID, "DVI-D" }, 159 - { DRM_MODE_CONNECTOR_DVIA, "DVI-A" }, 160 - { DRM_MODE_CONNECTOR_Composite, "Composite" }, 161 - { DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO" }, 162 - { DRM_MODE_CONNECTOR_LVDS, "LVDS" }, 163 - { DRM_MODE_CONNECTOR_Component, "Component" }, 164 - { DRM_MODE_CONNECTOR_9PinDIN, "DIN" }, 165 - { DRM_MODE_CONNECTOR_DisplayPort, "DP" }, 166 - { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" }, 167 - { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" }, 168 - { DRM_MODE_CONNECTOR_TV, "TV" }, 169 - { DRM_MODE_CONNECTOR_eDP, "eDP" }, 170 - { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, 171 - { DRM_MODE_CONNECTOR_DSI, "DSI" }, 172 - { DRM_MODE_CONNECTOR_DPI, "DPI" }, 173 55 }; 174 56 175 57 static const struct drm_prop_enum_list drm_encoder_enum_list[] = { ··· 66 184 { DRM_MODE_ENCODER_DPI, "DPI" }, 67 185 }; 68 186 69 - static const struct drm_prop_enum_list drm_subpixel_enum_list[] = { 70 - { SubPixelUnknown, "Unknown" }, 71 - { SubPixelHorizontalRGB, "Horizontal RGB" }, 72 - { SubPixelHorizontalBGR, "Horizontal BGR" }, 73 - { SubPixelVerticalRGB, "Vertical RGB" }, 74 - { SubPixelVerticalBGR, "Vertical BGR" }, 75 - { SubPixelNone, "None" }, 76 - }; 77 - 78 - void drm_connector_ida_init(void) 79 - { 80 - int i; 81 - 82 - for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) 83 - ida_init(&drm_connector_enum_list[i].ida); 84 - } 85 - 86 - void drm_connector_ida_destroy(void) 87 - { 88 - int i; 89 - 90 - for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) 91 - ida_destroy(&drm_connector_enum_list[i].ida); 92 - } 93 - 94 - /** 95 - * drm_get_connector_status_name - return a string for connector status 96 - * @status: connector status to compute name of 97 - * 98 - * In contrast to the other drm_get_*_name functions this one here returns a 99 - * const pointer and hence is threadsafe. 187 + /* 188 + * Optional properties 100 189 */ 101 - const char *drm_get_connector_status_name(enum drm_connector_status status) 102 - { 103 - if (status == connector_status_connected) 104 - return "connected"; 105 - else if (status == connector_status_disconnected) 106 - return "disconnected"; 107 - else 108 - return "unknown"; 109 - } 110 - EXPORT_SYMBOL(drm_get_connector_status_name); 111 - 112 - /** 113 - * drm_get_subpixel_order_name - return a string for a given subpixel enum 114 - * @order: enum of subpixel_order 115 - * 116 - * Note you could abuse this and return something out of bounds, but that 117 - * would be a caller error. No unscrubbed user data should make it here. 118 - */ 119 - const char *drm_get_subpixel_order_name(enum subpixel_order order) 120 - { 121 - return drm_subpixel_enum_list[order].name; 122 - } 123 - EXPORT_SYMBOL(drm_get_subpixel_order_name); 124 - 125 190 /* 126 191 * Internal function to assign a slot in the object idr and optionally 127 192 * register the object into the idr. 128 193 */ 129 - static int drm_mode_object_get_reg(struct drm_device *dev, 130 - struct drm_mode_object *obj, 131 - uint32_t obj_type, 132 - bool register_obj, 133 - void (*obj_free_cb)(struct kref *kref)) 194 + int drm_mode_object_get_reg(struct drm_device *dev, 195 + struct drm_mode_object *obj, 196 + uint32_t obj_type, 197 + bool register_obj, 198 + void (*obj_free_cb)(struct kref *kref)) 134 199 { 135 200 int ret; 136 201 ··· 120 291 return drm_mode_object_get_reg(dev, obj, obj_type, true, NULL); 121 292 } 122 293 123 - static void drm_mode_object_register(struct drm_device *dev, 124 - struct drm_mode_object *obj) 294 + void drm_mode_object_register(struct drm_device *dev, 295 + struct drm_mode_object *obj) 125 296 { 126 297 mutex_lock(&dev->mode_config.idr_mutex); 127 298 idr_replace(&dev->mode_config.crtc_idr, obj, obj->id); ··· 150 321 mutex_unlock(&dev->mode_config.idr_mutex); 151 322 } 152 323 153 - static struct drm_mode_object *_object_find(struct drm_device *dev, 154 - uint32_t id, uint32_t type) 324 + struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev, 325 + uint32_t id, uint32_t type) 155 326 { 156 327 struct drm_mode_object *obj = NULL; 157 328 ··· 186 357 { 187 358 struct drm_mode_object *obj = NULL; 188 359 189 - obj = _object_find(dev, id, type); 360 + obj = __drm_mode_object_find(dev, id, type); 190 361 return obj; 191 362 } 192 363 EXPORT_SYMBOL(drm_mode_object_find); ··· 269 440 return ret; 270 441 } 271 442 EXPORT_SYMBOL(drm_crtc_force_disable_all); 272 - 273 - static void drm_framebuffer_free(struct kref *kref) 274 - { 275 - struct drm_framebuffer *fb = 276 - container_of(kref, struct drm_framebuffer, base.refcount); 277 - struct drm_device *dev = fb->dev; 278 - 279 - /* 280 - * The lookup idr holds a weak reference, which has not necessarily been 281 - * removed at this point. Check for that. 282 - */ 283 - drm_mode_object_unregister(dev, &fb->base); 284 - 285 - fb->funcs->destroy(fb); 286 - } 287 - 288 - /** 289 - * drm_framebuffer_init - initialize a framebuffer 290 - * @dev: DRM device 291 - * @fb: framebuffer to be initialized 292 - * @funcs: ... with these functions 293 - * 294 - * Allocates an ID for the framebuffer's parent mode object, sets its mode 295 - * functions & device file and adds it to the master fd list. 296 - * 297 - * IMPORTANT: 298 - * This functions publishes the fb and makes it available for concurrent access 299 - * by other users. Which means by this point the fb _must_ be fully set up - 300 - * since all the fb attributes are invariant over its lifetime, no further 301 - * locking but only correct reference counting is required. 302 - * 303 - * Returns: 304 - * Zero on success, error code on failure. 305 - */ 306 - int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, 307 - const struct drm_framebuffer_funcs *funcs) 308 - { 309 - int ret; 310 - 311 - INIT_LIST_HEAD(&fb->filp_head); 312 - fb->dev = dev; 313 - fb->funcs = funcs; 314 - 315 - ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB, 316 - false, drm_framebuffer_free); 317 - if (ret) 318 - goto out; 319 - 320 - mutex_lock(&dev->mode_config.fb_lock); 321 - dev->mode_config.num_fb++; 322 - list_add(&fb->head, &dev->mode_config.fb_list); 323 - mutex_unlock(&dev->mode_config.fb_lock); 324 - 325 - drm_mode_object_register(dev, &fb->base); 326 - out: 327 - return ret; 328 - } 329 - EXPORT_SYMBOL(drm_framebuffer_init); 330 - 331 - /** 332 - * drm_framebuffer_lookup - look up a drm framebuffer and grab a reference 333 - * @dev: drm device 334 - * @id: id of the fb object 335 - * 336 - * If successful, this grabs an additional reference to the framebuffer - 337 - * callers need to make sure to eventually unreference the returned framebuffer 338 - * again, using @drm_framebuffer_unreference. 339 - */ 340 - struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, 341 - uint32_t id) 342 - { 343 - struct drm_mode_object *obj; 344 - struct drm_framebuffer *fb = NULL; 345 - 346 - obj = _object_find(dev, id, DRM_MODE_OBJECT_FB); 347 - if (obj) 348 - fb = obj_to_fb(obj); 349 - return fb; 350 - } 351 - EXPORT_SYMBOL(drm_framebuffer_lookup); 352 - 353 - /** 354 - * drm_framebuffer_unregister_private - unregister a private fb from the lookup idr 355 - * @fb: fb to unregister 356 - * 357 - * Drivers need to call this when cleaning up driver-private framebuffers, e.g. 358 - * those used for fbdev. Note that the caller must hold a reference of it's own, 359 - * i.e. the object may not be destroyed through this call (since it'll lead to a 360 - * locking inversion). 361 - */ 362 - void drm_framebuffer_unregister_private(struct drm_framebuffer *fb) 363 - { 364 - struct drm_device *dev; 365 - 366 - if (!fb) 367 - return; 368 - 369 - dev = fb->dev; 370 - 371 - /* Mark fb as reaped and drop idr ref. */ 372 - drm_mode_object_unregister(dev, &fb->base); 373 - } 374 - EXPORT_SYMBOL(drm_framebuffer_unregister_private); 375 - 376 - /** 377 - * drm_framebuffer_cleanup - remove a framebuffer object 378 - * @fb: framebuffer to remove 379 - * 380 - * Cleanup framebuffer. This function is intended to be used from the drivers 381 - * ->destroy callback. It can also be used to clean up driver private 382 - * framebuffers embedded into a larger structure. 383 - * 384 - * Note that this function does not remove the fb from active usuage - if it is 385 - * still used anywhere, hilarity can ensue since userspace could call getfb on 386 - * the id and get back -EINVAL. Obviously no concern at driver unload time. 387 - * 388 - * Also, the framebuffer will not be removed from the lookup idr - for 389 - * user-created framebuffers this will happen in in the rmfb ioctl. For 390 - * driver-private objects (e.g. for fbdev) drivers need to explicitly call 391 - * drm_framebuffer_unregister_private. 392 - */ 393 - void drm_framebuffer_cleanup(struct drm_framebuffer *fb) 394 - { 395 - struct drm_device *dev = fb->dev; 396 - 397 - mutex_lock(&dev->mode_config.fb_lock); 398 - list_del(&fb->head); 399 - dev->mode_config.num_fb--; 400 - mutex_unlock(&dev->mode_config.fb_lock); 401 - } 402 - EXPORT_SYMBOL(drm_framebuffer_cleanup); 403 - 404 - /** 405 - * drm_framebuffer_remove - remove and unreference a framebuffer object 406 - * @fb: framebuffer to remove 407 - * 408 - * Scans all the CRTCs and planes in @dev's mode_config. If they're 409 - * using @fb, removes it, setting it to NULL. Then drops the reference to the 410 - * passed-in framebuffer. Might take the modeset locks. 411 - * 412 - * Note that this function optimizes the cleanup away if the caller holds the 413 - * last reference to the framebuffer. It is also guaranteed to not take the 414 - * modeset locks in this case. 415 - */ 416 - void drm_framebuffer_remove(struct drm_framebuffer *fb) 417 - { 418 - struct drm_device *dev; 419 - struct drm_crtc *crtc; 420 - struct drm_plane *plane; 421 - 422 - if (!fb) 423 - return; 424 - 425 - dev = fb->dev; 426 - 427 - WARN_ON(!list_empty(&fb->filp_head)); 428 - 429 - /* 430 - * drm ABI mandates that we remove any deleted framebuffers from active 431 - * useage. But since most sane clients only remove framebuffers they no 432 - * longer need, try to optimize this away. 433 - * 434 - * Since we're holding a reference ourselves, observing a refcount of 1 435 - * means that we're the last holder and can skip it. Also, the refcount 436 - * can never increase from 1 again, so we don't need any barriers or 437 - * locks. 438 - * 439 - * Note that userspace could try to race with use and instate a new 440 - * usage _after_ we've cleared all current ones. End result will be an 441 - * in-use fb with fb-id == 0. Userspace is allowed to shoot its own foot 442 - * in this manner. 443 - */ 444 - if (drm_framebuffer_read_refcount(fb) > 1) { 445 - drm_modeset_lock_all(dev); 446 - /* remove from any CRTC */ 447 - drm_for_each_crtc(crtc, dev) { 448 - if (crtc->primary->fb == fb) { 449 - /* should turn off the crtc */ 450 - if (drm_crtc_force_disable(crtc)) 451 - DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc); 452 - } 453 - } 454 - 455 - drm_for_each_plane(plane, dev) { 456 - if (plane->fb == fb) 457 - drm_plane_force_disable(plane); 458 - } 459 - drm_modeset_unlock_all(dev); 460 - } 461 - 462 - drm_framebuffer_unreference(fb); 463 - } 464 - EXPORT_SYMBOL(drm_framebuffer_remove); 465 443 466 444 DEFINE_WW_CLASS(crtc_ww_class); 467 445 ··· 419 783 } 420 784 EXPORT_SYMBOL(drm_crtc_cleanup); 421 785 422 - /* 423 - * drm_mode_remove - remove and free a mode 424 - * @connector: connector list to modify 425 - * @mode: mode to remove 426 - * 427 - * Remove @mode from @connector's mode list, then free it. 428 - */ 429 - static void drm_mode_remove(struct drm_connector *connector, 430 - struct drm_display_mode *mode) 431 - { 432 - list_del(&mode->head); 433 - drm_mode_destroy(connector->dev, mode); 434 - } 435 - 436 - /** 437 - * drm_display_info_set_bus_formats - set the supported bus formats 438 - * @info: display info to store bus formats in 439 - * @formats: array containing the supported bus formats 440 - * @num_formats: the number of entries in the fmts array 441 - * 442 - * Store the supported bus formats in display info structure. 443 - * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for 444 - * a full list of available formats. 445 - */ 446 - int drm_display_info_set_bus_formats(struct drm_display_info *info, 447 - const u32 *formats, 448 - unsigned int num_formats) 449 - { 450 - u32 *fmts = NULL; 451 - 452 - if (!formats && num_formats) 453 - return -EINVAL; 454 - 455 - if (formats && num_formats) { 456 - fmts = kmemdup(formats, sizeof(*formats) * num_formats, 457 - GFP_KERNEL); 458 - if (!fmts) 459 - return -ENOMEM; 460 - } 461 - 462 - kfree(info->bus_formats); 463 - info->bus_formats = fmts; 464 - info->num_bus_formats = num_formats; 465 - 466 - return 0; 467 - } 468 - EXPORT_SYMBOL(drm_display_info_set_bus_formats); 469 - 470 - /** 471 - * drm_connector_get_cmdline_mode - reads the user's cmdline mode 472 - * @connector: connector to quwery 473 - * 474 - * The kernel supports per-connector configration of its consoles through 475 - * use of the video= parameter. This function parses that option and 476 - * extracts the user's specified mode (or enable/disable status) for a 477 - * particular connector. This is typically only used during the early fbdev 478 - * setup. 479 - */ 480 - static void drm_connector_get_cmdline_mode(struct drm_connector *connector) 481 - { 482 - struct drm_cmdline_mode *mode = &connector->cmdline_mode; 483 - char *option = NULL; 484 - 485 - if (fb_get_options(connector->name, &option)) 486 - return; 487 - 488 - if (!drm_mode_parse_command_line_for_connector(option, 489 - connector, 490 - mode)) 491 - return; 492 - 493 - if (mode->force) { 494 - const char *s; 495 - 496 - switch (mode->force) { 497 - case DRM_FORCE_OFF: 498 - s = "OFF"; 499 - break; 500 - case DRM_FORCE_ON_DIGITAL: 501 - s = "ON - dig"; 502 - break; 503 - default: 504 - case DRM_FORCE_ON: 505 - s = "ON"; 506 - break; 507 - } 508 - 509 - DRM_INFO("forcing %s connector %s\n", connector->name, s); 510 - connector->force = mode->force; 511 - } 512 - 513 - DRM_DEBUG_KMS("cmdline mode for connector %s %dx%d@%dHz%s%s%s\n", 514 - connector->name, 515 - mode->xres, mode->yres, 516 - mode->refresh_specified ? mode->refresh : 60, 517 - mode->rb ? " reduced blanking" : "", 518 - mode->margins ? " with margins" : "", 519 - mode->interlace ? " interlaced" : ""); 520 - } 521 - 522 - static void drm_connector_free(struct kref *kref) 523 - { 524 - struct drm_connector *connector = 525 - container_of(kref, struct drm_connector, base.refcount); 526 - struct drm_device *dev = connector->dev; 527 - 528 - drm_mode_object_unregister(dev, &connector->base); 529 - connector->funcs->destroy(connector); 530 - } 531 - 532 - /** 533 - * drm_connector_init - Init a preallocated connector 534 - * @dev: DRM device 535 - * @connector: the connector to init 536 - * @funcs: callbacks for this connector 537 - * @connector_type: user visible type of the connector 538 - * 539 - * Initialises a preallocated connector. Connectors should be 540 - * subclassed as part of driver connector objects. 541 - * 542 - * Returns: 543 - * Zero on success, error code on failure. 544 - */ 545 - int drm_connector_init(struct drm_device *dev, 546 - struct drm_connector *connector, 547 - const struct drm_connector_funcs *funcs, 548 - int connector_type) 549 - { 550 - struct drm_mode_config *config = &dev->mode_config; 551 - int ret; 552 - struct ida *connector_ida = 553 - &drm_connector_enum_list[connector_type].ida; 554 - 555 - drm_modeset_lock_all(dev); 556 - 557 - ret = drm_mode_object_get_reg(dev, &connector->base, 558 - DRM_MODE_OBJECT_CONNECTOR, 559 - false, drm_connector_free); 560 - if (ret) 561 - goto out_unlock; 562 - 563 - connector->base.properties = &connector->properties; 564 - connector->dev = dev; 565 - connector->funcs = funcs; 566 - 567 - ret = ida_simple_get(&config->connector_ida, 0, 0, GFP_KERNEL); 568 - if (ret < 0) 569 - goto out_put; 570 - connector->index = ret; 571 - ret = 0; 572 - 573 - connector->connector_type = connector_type; 574 - connector->connector_type_id = 575 - ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); 576 - if (connector->connector_type_id < 0) { 577 - ret = connector->connector_type_id; 578 - goto out_put_id; 579 - } 580 - connector->name = 581 - kasprintf(GFP_KERNEL, "%s-%d", 582 - drm_connector_enum_list[connector_type].name, 583 - connector->connector_type_id); 584 - if (!connector->name) { 585 - ret = -ENOMEM; 586 - goto out_put_type_id; 587 - } 588 - 589 - INIT_LIST_HEAD(&connector->probed_modes); 590 - INIT_LIST_HEAD(&connector->modes); 591 - connector->edid_blob_ptr = NULL; 592 - connector->status = connector_status_unknown; 593 - 594 - drm_connector_get_cmdline_mode(connector); 595 - 596 - /* We should add connectors at the end to avoid upsetting the connector 597 - * index too much. */ 598 - list_add_tail(&connector->head, &config->connector_list); 599 - config->num_connector++; 600 - 601 - if (connector_type != DRM_MODE_CONNECTOR_VIRTUAL) 602 - drm_object_attach_property(&connector->base, 603 - config->edid_property, 604 - 0); 605 - 606 - drm_object_attach_property(&connector->base, 607 - config->dpms_property, 0); 608 - 609 - if (drm_core_check_feature(dev, DRIVER_ATOMIC)) { 610 - drm_object_attach_property(&connector->base, config->prop_crtc_id, 0); 611 - } 612 - 613 - connector->debugfs_entry = NULL; 614 - out_put_type_id: 615 - if (ret) 616 - ida_remove(connector_ida, connector->connector_type_id); 617 - out_put_id: 618 - if (ret) 619 - ida_remove(&config->connector_ida, connector->index); 620 - out_put: 621 - if (ret) 622 - drm_mode_object_unregister(dev, &connector->base); 623 - 624 - out_unlock: 625 - drm_modeset_unlock_all(dev); 626 - 627 - return ret; 628 - } 629 - EXPORT_SYMBOL(drm_connector_init); 630 - 631 - /** 632 - * drm_connector_cleanup - cleans up an initialised connector 633 - * @connector: connector to cleanup 634 - * 635 - * Cleans up the connector but doesn't free the object. 636 - */ 637 - void drm_connector_cleanup(struct drm_connector *connector) 638 - { 639 - struct drm_device *dev = connector->dev; 640 - struct drm_display_mode *mode, *t; 641 - 642 - /* The connector should have been removed from userspace long before 643 - * it is finally destroyed. 644 - */ 645 - if (WARN_ON(connector->registered)) 646 - drm_connector_unregister(connector); 647 - 648 - if (connector->tile_group) { 649 - drm_mode_put_tile_group(dev, connector->tile_group); 650 - connector->tile_group = NULL; 651 - } 652 - 653 - list_for_each_entry_safe(mode, t, &connector->probed_modes, head) 654 - drm_mode_remove(connector, mode); 655 - 656 - list_for_each_entry_safe(mode, t, &connector->modes, head) 657 - drm_mode_remove(connector, mode); 658 - 659 - ida_remove(&drm_connector_enum_list[connector->connector_type].ida, 660 - connector->connector_type_id); 661 - 662 - ida_remove(&dev->mode_config.connector_ida, 663 - connector->index); 664 - 665 - kfree(connector->display_info.bus_formats); 666 - drm_mode_object_unregister(dev, &connector->base); 667 - kfree(connector->name); 668 - connector->name = NULL; 669 - list_del(&connector->head); 670 - dev->mode_config.num_connector--; 671 - 672 - WARN_ON(connector->state && !connector->funcs->atomic_destroy_state); 673 - if (connector->state && connector->funcs->atomic_destroy_state) 674 - connector->funcs->atomic_destroy_state(connector, 675 - connector->state); 676 - 677 - memset(connector, 0, sizeof(*connector)); 678 - } 679 - EXPORT_SYMBOL(drm_connector_cleanup); 680 - 681 - /** 682 - * drm_connector_register - register a connector 683 - * @connector: the connector to register 684 - * 685 - * Register userspace interfaces for a connector 686 - * 687 - * Returns: 688 - * Zero on success, error code on failure. 689 - */ 690 - int drm_connector_register(struct drm_connector *connector) 691 - { 692 - int ret; 693 - 694 - if (connector->registered) 695 - return 0; 696 - 697 - ret = drm_sysfs_connector_add(connector); 698 - if (ret) 699 - return ret; 700 - 701 - ret = drm_debugfs_connector_add(connector); 702 - if (ret) { 703 - goto err_sysfs; 704 - } 705 - 706 - if (connector->funcs->late_register) { 707 - ret = connector->funcs->late_register(connector); 708 - if (ret) 709 - goto err_debugfs; 710 - } 711 - 712 - drm_mode_object_register(connector->dev, &connector->base); 713 - 714 - connector->registered = true; 715 - return 0; 716 - 717 - err_debugfs: 718 - drm_debugfs_connector_remove(connector); 719 - err_sysfs: 720 - drm_sysfs_connector_remove(connector); 721 - return ret; 722 - } 723 - EXPORT_SYMBOL(drm_connector_register); 724 - 725 - /** 726 - * drm_connector_unregister - unregister a connector 727 - * @connector: the connector to unregister 728 - * 729 - * Unregister userspace interfaces for a connector 730 - */ 731 - void drm_connector_unregister(struct drm_connector *connector) 732 - { 733 - if (!connector->registered) 734 - return; 735 - 736 - if (connector->funcs->early_unregister) 737 - connector->funcs->early_unregister(connector); 738 - 739 - drm_sysfs_connector_remove(connector); 740 - drm_debugfs_connector_remove(connector); 741 - 742 - connector->registered = false; 743 - } 744 - EXPORT_SYMBOL(drm_connector_unregister); 745 - 746 - static void drm_connector_unregister_all(struct drm_device *dev) 747 - { 748 - struct drm_connector *connector; 749 - 750 - /* FIXME: taking the mode config mutex ends up in a clash with sysfs */ 751 - list_for_each_entry(connector, &dev->mode_config.connector_list, head) 752 - drm_connector_unregister(connector); 753 - } 754 - 755 - static int drm_connector_register_all(struct drm_device *dev) 756 - { 757 - struct drm_connector *connector; 758 - int ret; 759 - 760 - /* FIXME: taking the mode config mutex ends up in a clash with 761 - * fbcon/backlight registration */ 762 - list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 763 - ret = drm_connector_register(connector); 764 - if (ret) 765 - goto err; 766 - } 767 - 768 - return 0; 769 - 770 - err: 771 - mutex_unlock(&dev->mode_config.mutex); 772 - drm_connector_unregister_all(dev); 773 - return ret; 774 - } 775 - 776 786 static int drm_encoder_register_all(struct drm_device *dev) 777 787 { 778 788 struct drm_encoder *encoder; ··· 548 1266 * @plane: plane object to init 549 1267 * @possible_crtcs: bitmask of possible CRTCs 550 1268 * @funcs: callbacks for the new plane 551 - * @formats: array of supported formats (%DRM_FORMAT_*) 1269 + * @formats: array of supported formats (DRM_FORMAT\_\*) 552 1270 * @format_count: number of elements in @formats 553 1271 * @type: type of plane (overlay, primary, cursor) 554 1272 * @name: printf style format string for the plane name, or NULL for default name ··· 663 1381 * @plane: plane object to init 664 1382 * @possible_crtcs: bitmask of possible CRTCs 665 1383 * @funcs: callbacks for the new plane 666 - * @formats: array of supported formats (%DRM_FORMAT_*) 1384 + * @formats: array of supported formats (DRM_FORMAT\_\*) 667 1385 * @format_count: number of elements in @formats 668 1386 * @is_primary: plane type (primary vs overlay) 669 1387 * ··· 822 1540 static int drm_mode_create_standard_properties(struct drm_device *dev) 823 1541 { 824 1542 struct drm_property *prop; 1543 + int ret; 825 1544 826 - /* 827 - * Standard properties (apply to all connectors) 828 - */ 829 - prop = drm_property_create(dev, DRM_MODE_PROP_BLOB | 830 - DRM_MODE_PROP_IMMUTABLE, 831 - "EDID", 0); 832 - if (!prop) 833 - return -ENOMEM; 834 - dev->mode_config.edid_property = prop; 835 - 836 - prop = drm_property_create_enum(dev, 0, 837 - "DPMS", drm_dpms_enum_list, 838 - ARRAY_SIZE(drm_dpms_enum_list)); 839 - if (!prop) 840 - return -ENOMEM; 841 - dev->mode_config.dpms_property = prop; 842 - 843 - prop = drm_property_create(dev, 844 - DRM_MODE_PROP_BLOB | 845 - DRM_MODE_PROP_IMMUTABLE, 846 - "PATH", 0); 847 - if (!prop) 848 - return -ENOMEM; 849 - dev->mode_config.path_property = prop; 850 - 851 - prop = drm_property_create(dev, 852 - DRM_MODE_PROP_BLOB | 853 - DRM_MODE_PROP_IMMUTABLE, 854 - "TILE", 0); 855 - if (!prop) 856 - return -ENOMEM; 857 - dev->mode_config.tile_property = prop; 1545 + ret = drm_connector_create_standard_properties(dev); 1546 + if (ret) 1547 + return ret; 858 1548 859 1549 prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, 860 1550 "type", drm_plane_type_enum_list, ··· 945 1691 946 1692 return 0; 947 1693 } 948 - 949 - /** 950 - * drm_mode_create_dvi_i_properties - create DVI-I specific connector properties 951 - * @dev: DRM device 952 - * 953 - * Called by a driver the first time a DVI-I connector is made. 954 - */ 955 - int drm_mode_create_dvi_i_properties(struct drm_device *dev) 956 - { 957 - struct drm_property *dvi_i_selector; 958 - struct drm_property *dvi_i_subconnector; 959 - 960 - if (dev->mode_config.dvi_i_select_subconnector_property) 961 - return 0; 962 - 963 - dvi_i_selector = 964 - drm_property_create_enum(dev, 0, 965 - "select subconnector", 966 - drm_dvi_i_select_enum_list, 967 - ARRAY_SIZE(drm_dvi_i_select_enum_list)); 968 - dev->mode_config.dvi_i_select_subconnector_property = dvi_i_selector; 969 - 970 - dvi_i_subconnector = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, 971 - "subconnector", 972 - drm_dvi_i_subconnector_enum_list, 973 - ARRAY_SIZE(drm_dvi_i_subconnector_enum_list)); 974 - dev->mode_config.dvi_i_subconnector_property = dvi_i_subconnector; 975 - 976 - return 0; 977 - } 978 - EXPORT_SYMBOL(drm_mode_create_dvi_i_properties); 979 - 980 - /** 981 - * drm_create_tv_properties - create TV specific connector properties 982 - * @dev: DRM device 983 - * @num_modes: number of different TV formats (modes) supported 984 - * @modes: array of pointers to strings containing name of each format 985 - * 986 - * Called by a driver's TV initialization routine, this function creates 987 - * the TV specific connector properties for a given device. Caller is 988 - * responsible for allocating a list of format names and passing them to 989 - * this routine. 990 - */ 991 - int drm_mode_create_tv_properties(struct drm_device *dev, 992 - unsigned int num_modes, 993 - const char * const modes[]) 994 - { 995 - struct drm_property *tv_selector; 996 - struct drm_property *tv_subconnector; 997 - unsigned int i; 998 - 999 - if (dev->mode_config.tv_select_subconnector_property) 1000 - return 0; 1001 - 1002 - /* 1003 - * Basic connector properties 1004 - */ 1005 - tv_selector = drm_property_create_enum(dev, 0, 1006 - "select subconnector", 1007 - drm_tv_select_enum_list, 1008 - ARRAY_SIZE(drm_tv_select_enum_list)); 1009 - if (!tv_selector) 1010 - goto nomem; 1011 - 1012 - dev->mode_config.tv_select_subconnector_property = tv_selector; 1013 - 1014 - tv_subconnector = 1015 - drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, 1016 - "subconnector", 1017 - drm_tv_subconnector_enum_list, 1018 - ARRAY_SIZE(drm_tv_subconnector_enum_list)); 1019 - if (!tv_subconnector) 1020 - goto nomem; 1021 - dev->mode_config.tv_subconnector_property = tv_subconnector; 1022 - 1023 - /* 1024 - * Other, TV specific properties: margins & TV modes. 1025 - */ 1026 - dev->mode_config.tv_left_margin_property = 1027 - drm_property_create_range(dev, 0, "left margin", 0, 100); 1028 - if (!dev->mode_config.tv_left_margin_property) 1029 - goto nomem; 1030 - 1031 - dev->mode_config.tv_right_margin_property = 1032 - drm_property_create_range(dev, 0, "right margin", 0, 100); 1033 - if (!dev->mode_config.tv_right_margin_property) 1034 - goto nomem; 1035 - 1036 - dev->mode_config.tv_top_margin_property = 1037 - drm_property_create_range(dev, 0, "top margin", 0, 100); 1038 - if (!dev->mode_config.tv_top_margin_property) 1039 - goto nomem; 1040 - 1041 - dev->mode_config.tv_bottom_margin_property = 1042 - drm_property_create_range(dev, 0, "bottom margin", 0, 100); 1043 - if (!dev->mode_config.tv_bottom_margin_property) 1044 - goto nomem; 1045 - 1046 - dev->mode_config.tv_mode_property = 1047 - drm_property_create(dev, DRM_MODE_PROP_ENUM, 1048 - "mode", num_modes); 1049 - if (!dev->mode_config.tv_mode_property) 1050 - goto nomem; 1051 - 1052 - for (i = 0; i < num_modes; i++) 1053 - drm_property_add_enum(dev->mode_config.tv_mode_property, i, 1054 - i, modes[i]); 1055 - 1056 - dev->mode_config.tv_brightness_property = 1057 - drm_property_create_range(dev, 0, "brightness", 0, 100); 1058 - if (!dev->mode_config.tv_brightness_property) 1059 - goto nomem; 1060 - 1061 - dev->mode_config.tv_contrast_property = 1062 - drm_property_create_range(dev, 0, "contrast", 0, 100); 1063 - if (!dev->mode_config.tv_contrast_property) 1064 - goto nomem; 1065 - 1066 - dev->mode_config.tv_flicker_reduction_property = 1067 - drm_property_create_range(dev, 0, "flicker reduction", 0, 100); 1068 - if (!dev->mode_config.tv_flicker_reduction_property) 1069 - goto nomem; 1070 - 1071 - dev->mode_config.tv_overscan_property = 1072 - drm_property_create_range(dev, 0, "overscan", 0, 100); 1073 - if (!dev->mode_config.tv_overscan_property) 1074 - goto nomem; 1075 - 1076 - dev->mode_config.tv_saturation_property = 1077 - drm_property_create_range(dev, 0, "saturation", 0, 100); 1078 - if (!dev->mode_config.tv_saturation_property) 1079 - goto nomem; 1080 - 1081 - dev->mode_config.tv_hue_property = 1082 - drm_property_create_range(dev, 0, "hue", 0, 100); 1083 - if (!dev->mode_config.tv_hue_property) 1084 - goto nomem; 1085 - 1086 - return 0; 1087 - nomem: 1088 - return -ENOMEM; 1089 - } 1090 - EXPORT_SYMBOL(drm_mode_create_tv_properties); 1091 - 1092 - /** 1093 - * drm_mode_create_scaling_mode_property - create scaling mode property 1094 - * @dev: DRM device 1095 - * 1096 - * Called by a driver the first time it's needed, must be attached to desired 1097 - * connectors. 1098 - */ 1099 - int drm_mode_create_scaling_mode_property(struct drm_device *dev) 1100 - { 1101 - struct drm_property *scaling_mode; 1102 - 1103 - if (dev->mode_config.scaling_mode_property) 1104 - return 0; 1105 - 1106 - scaling_mode = 1107 - drm_property_create_enum(dev, 0, "scaling mode", 1108 - drm_scaling_mode_enum_list, 1109 - ARRAY_SIZE(drm_scaling_mode_enum_list)); 1110 - 1111 - dev->mode_config.scaling_mode_property = scaling_mode; 1112 - 1113 - return 0; 1114 - } 1115 - EXPORT_SYMBOL(drm_mode_create_scaling_mode_property); 1116 - 1117 - /** 1118 - * drm_mode_create_aspect_ratio_property - create aspect ratio property 1119 - * @dev: DRM device 1120 - * 1121 - * Called by a driver the first time it's needed, must be attached to desired 1122 - * connectors. 1123 - * 1124 - * Returns: 1125 - * Zero on success, negative errno on failure. 1126 - */ 1127 - int drm_mode_create_aspect_ratio_property(struct drm_device *dev) 1128 - { 1129 - if (dev->mode_config.aspect_ratio_property) 1130 - return 0; 1131 - 1132 - dev->mode_config.aspect_ratio_property = 1133 - drm_property_create_enum(dev, 0, "aspect ratio", 1134 - drm_aspect_ratio_enum_list, 1135 - ARRAY_SIZE(drm_aspect_ratio_enum_list)); 1136 - 1137 - if (dev->mode_config.aspect_ratio_property == NULL) 1138 - return -ENOMEM; 1139 - 1140 - return 0; 1141 - } 1142 - EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property); 1143 - 1144 - /** 1145 - * drm_mode_create_dirty_property - create dirty property 1146 - * @dev: DRM device 1147 - * 1148 - * Called by a driver the first time it's needed, must be attached to desired 1149 - * connectors. 1150 - */ 1151 - int drm_mode_create_dirty_info_property(struct drm_device *dev) 1152 - { 1153 - struct drm_property *dirty_info; 1154 - 1155 - if (dev->mode_config.dirty_info_property) 1156 - return 0; 1157 - 1158 - dirty_info = 1159 - drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, 1160 - "dirty", 1161 - drm_dirty_info_enum_list, 1162 - ARRAY_SIZE(drm_dirty_info_enum_list)); 1163 - dev->mode_config.dirty_info_property = dirty_info; 1164 - 1165 - return 0; 1166 - } 1167 - EXPORT_SYMBOL(drm_mode_create_dirty_info_property); 1168 - 1169 - /** 1170 - * drm_mode_create_suggested_offset_properties - create suggests offset properties 1171 - * @dev: DRM device 1172 - * 1173 - * Create the the suggested x/y offset property for connectors. 1174 - */ 1175 - int drm_mode_create_suggested_offset_properties(struct drm_device *dev) 1176 - { 1177 - if (dev->mode_config.suggested_x_property && dev->mode_config.suggested_y_property) 1178 - return 0; 1179 - 1180 - dev->mode_config.suggested_x_property = 1181 - drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, "suggested X", 0, 0xffffffff); 1182 - 1183 - dev->mode_config.suggested_y_property = 1184 - drm_property_create_range(dev, DRM_MODE_PROP_IMMUTABLE, "suggested Y", 0, 0xffffffff); 1185 - 1186 - if (dev->mode_config.suggested_x_property == NULL || 1187 - dev->mode_config.suggested_y_property == NULL) 1188 - return -ENOMEM; 1189 - return 0; 1190 - } 1191 - EXPORT_SYMBOL(drm_mode_create_suggested_offset_properties); 1192 1694 1193 1695 /** 1194 1696 * drm_mode_getresources - get graphics configuration ··· 1133 2123 return 0; 1134 2124 } 1135 2125 1136 - static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode, 1137 - const struct drm_file *file_priv) 1138 - { 1139 - /* 1140 - * If user-space hasn't configured the driver to expose the stereo 3D 1141 - * modes, don't expose them. 1142 - */ 1143 - if (!file_priv->stereo_allowed && drm_mode_is_stereo(mode)) 1144 - return false; 1145 - 1146 - return true; 1147 - } 1148 - 1149 - static struct drm_encoder *drm_connector_get_encoder(struct drm_connector *connector) 1150 - { 1151 - /* For atomic drivers only state objects are synchronously updated and 1152 - * protected by modeset locks, so check those first. */ 1153 - if (connector->state) 1154 - return connector->state->best_encoder; 1155 - return connector->encoder; 1156 - } 1157 - 1158 2126 /* helper for getconnector and getproperties ioctls */ 1159 - static int get_properties(struct drm_mode_object *obj, bool atomic, 1160 - uint32_t __user *prop_ptr, uint64_t __user *prop_values, 1161 - uint32_t *arg_count_props) 2127 + int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, 2128 + uint32_t __user *prop_ptr, 2129 + uint64_t __user *prop_values, 2130 + uint32_t *arg_count_props) 1162 2131 { 1163 2132 int props_count; 1164 2133 int i, ret, copied; ··· 1170 2181 *arg_count_props = props_count; 1171 2182 1172 2183 return 0; 1173 - } 1174 - 1175 - /** 1176 - * drm_mode_getconnector - get connector configuration 1177 - * @dev: drm device for the ioctl 1178 - * @data: data pointer for the ioctl 1179 - * @file_priv: drm file for the ioctl call 1180 - * 1181 - * Construct a connector configuration structure to return to the user. 1182 - * 1183 - * Called by the user via ioctl. 1184 - * 1185 - * Returns: 1186 - * Zero on success, negative errno on failure. 1187 - */ 1188 - int drm_mode_getconnector(struct drm_device *dev, void *data, 1189 - struct drm_file *file_priv) 1190 - { 1191 - struct drm_mode_get_connector *out_resp = data; 1192 - struct drm_connector *connector; 1193 - struct drm_encoder *encoder; 1194 - struct drm_display_mode *mode; 1195 - int mode_count = 0; 1196 - int encoders_count = 0; 1197 - int ret = 0; 1198 - int copied = 0; 1199 - int i; 1200 - struct drm_mode_modeinfo u_mode; 1201 - struct drm_mode_modeinfo __user *mode_ptr; 1202 - uint32_t __user *encoder_ptr; 1203 - 1204 - if (!drm_core_check_feature(dev, DRIVER_MODESET)) 1205 - return -EINVAL; 1206 - 1207 - memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); 1208 - 1209 - mutex_lock(&dev->mode_config.mutex); 1210 - 1211 - connector = drm_connector_lookup(dev, out_resp->connector_id); 1212 - if (!connector) { 1213 - ret = -ENOENT; 1214 - goto out_unlock; 1215 - } 1216 - 1217 - for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) 1218 - if (connector->encoder_ids[i] != 0) 1219 - encoders_count++; 1220 - 1221 - if (out_resp->count_modes == 0) { 1222 - connector->funcs->fill_modes(connector, 1223 - dev->mode_config.max_width, 1224 - dev->mode_config.max_height); 1225 - } 1226 - 1227 - /* delayed so we get modes regardless of pre-fill_modes state */ 1228 - list_for_each_entry(mode, &connector->modes, head) 1229 - if (drm_mode_expose_to_userspace(mode, file_priv)) 1230 - mode_count++; 1231 - 1232 - out_resp->connector_id = connector->base.id; 1233 - out_resp->connector_type = connector->connector_type; 1234 - out_resp->connector_type_id = connector->connector_type_id; 1235 - out_resp->mm_width = connector->display_info.width_mm; 1236 - out_resp->mm_height = connector->display_info.height_mm; 1237 - out_resp->subpixel = connector->display_info.subpixel_order; 1238 - out_resp->connection = connector->status; 1239 - 1240 - drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); 1241 - encoder = drm_connector_get_encoder(connector); 1242 - if (encoder) 1243 - out_resp->encoder_id = encoder->base.id; 1244 - else 1245 - out_resp->encoder_id = 0; 1246 - 1247 - /* 1248 - * This ioctl is called twice, once to determine how much space is 1249 - * needed, and the 2nd time to fill it. 1250 - */ 1251 - if ((out_resp->count_modes >= mode_count) && mode_count) { 1252 - copied = 0; 1253 - mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long)out_resp->modes_ptr; 1254 - list_for_each_entry(mode, &connector->modes, head) { 1255 - if (!drm_mode_expose_to_userspace(mode, file_priv)) 1256 - continue; 1257 - 1258 - drm_mode_convert_to_umode(&u_mode, mode); 1259 - if (copy_to_user(mode_ptr + copied, 1260 - &u_mode, sizeof(u_mode))) { 1261 - ret = -EFAULT; 1262 - goto out; 1263 - } 1264 - copied++; 1265 - } 1266 - } 1267 - out_resp->count_modes = mode_count; 1268 - 1269 - ret = get_properties(&connector->base, file_priv->atomic, 1270 - (uint32_t __user *)(unsigned long)(out_resp->props_ptr), 1271 - (uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr), 1272 - &out_resp->count_props); 1273 - if (ret) 1274 - goto out; 1275 - 1276 - if ((out_resp->count_encoders >= encoders_count) && encoders_count) { 1277 - copied = 0; 1278 - encoder_ptr = (uint32_t __user *)(unsigned long)(out_resp->encoders_ptr); 1279 - for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 1280 - if (connector->encoder_ids[i] != 0) { 1281 - if (put_user(connector->encoder_ids[i], 1282 - encoder_ptr + copied)) { 1283 - ret = -EFAULT; 1284 - goto out; 1285 - } 1286 - copied++; 1287 - } 1288 - } 1289 - } 1290 - out_resp->count_encoders = encoders_count; 1291 - 1292 - out: 1293 - drm_modeset_unlock(&dev->mode_config.connection_mutex); 1294 - 1295 - drm_connector_unreference(connector); 1296 - out_unlock: 1297 - mutex_unlock(&dev->mode_config.mutex); 1298 - 1299 - return ret; 1300 2184 } 1301 2185 1302 2186 static struct drm_crtc *drm_encoder_get_crtc(struct drm_encoder *encoder) ··· 1454 2592 /* Check whether this plane supports the fb pixel format. */ 1455 2593 ret = drm_plane_check_pixel_format(plane, fb->pixel_format); 1456 2594 if (ret) { 1457 - DRM_DEBUG_KMS("Invalid pixel format %s\n", 1458 - drm_get_format_name(fb->pixel_format)); 2595 + char *format_name = drm_get_format_name(fb->pixel_format); 2596 + DRM_DEBUG_KMS("Invalid pixel format %s\n", format_name); 2597 + kfree(format_name); 1459 2598 goto out; 1460 2599 } 1461 2600 ··· 1765 2902 ret = drm_plane_check_pixel_format(crtc->primary, 1766 2903 fb->pixel_format); 1767 2904 if (ret) { 1768 - DRM_DEBUG_KMS("Invalid pixel format %s\n", 1769 - drm_get_format_name(fb->pixel_format)); 2905 + char *format_name = drm_get_format_name(fb->pixel_format); 2906 + DRM_DEBUG_KMS("Invalid pixel format %s\n", format_name); 2907 + kfree(format_name); 1770 2908 goto out; 1771 2909 } 1772 2910 } ··· 1904 3040 */ 1905 3041 if (req->flags & DRM_MODE_CURSOR_BO) { 1906 3042 if (req->handle) { 1907 - fb = internal_framebuffer_create(dev, &fbreq, file_priv); 3043 + fb = drm_internal_framebuffer_create(dev, &fbreq, file_priv); 1908 3044 if (IS_ERR(fb)) { 1909 3045 DRM_DEBUG_KMS("failed to wrap cursor buffer in drm framebuffer\n"); 1910 3046 return PTR_ERR(fb); ··· 2101 3237 return fmt; 2102 3238 } 2103 3239 EXPORT_SYMBOL(drm_mode_legacy_fb_format); 2104 - 2105 - /** 2106 - * drm_mode_addfb - add an FB to the graphics configuration 2107 - * @dev: drm device for the ioctl 2108 - * @data: data pointer for the ioctl 2109 - * @file_priv: drm file for the ioctl call 2110 - * 2111 - * Add a new FB to the specified CRTC, given a user request. This is the 2112 - * original addfb ioctl which only supported RGB formats. 2113 - * 2114 - * Called by the user via ioctl. 2115 - * 2116 - * Returns: 2117 - * Zero on success, negative errno on failure. 2118 - */ 2119 - int drm_mode_addfb(struct drm_device *dev, 2120 - void *data, struct drm_file *file_priv) 2121 - { 2122 - struct drm_mode_fb_cmd *or = data; 2123 - struct drm_mode_fb_cmd2 r = {}; 2124 - int ret; 2125 - 2126 - /* convert to new format and call new ioctl */ 2127 - r.fb_id = or->fb_id; 2128 - r.width = or->width; 2129 - r.height = or->height; 2130 - r.pitches[0] = or->pitch; 2131 - r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth); 2132 - r.handles[0] = or->handle; 2133 - 2134 - ret = drm_mode_addfb2(dev, &r, file_priv); 2135 - if (ret) 2136 - return ret; 2137 - 2138 - or->fb_id = r.fb_id; 2139 - 2140 - return 0; 2141 - } 2142 - 2143 - static int format_check(const struct drm_mode_fb_cmd2 *r) 2144 - { 2145 - uint32_t format = r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN; 2146 - 2147 - switch (format) { 2148 - case DRM_FORMAT_C8: 2149 - case DRM_FORMAT_RGB332: 2150 - case DRM_FORMAT_BGR233: 2151 - case DRM_FORMAT_XRGB4444: 2152 - case DRM_FORMAT_XBGR4444: 2153 - case DRM_FORMAT_RGBX4444: 2154 - case DRM_FORMAT_BGRX4444: 2155 - case DRM_FORMAT_ARGB4444: 2156 - case DRM_FORMAT_ABGR4444: 2157 - case DRM_FORMAT_RGBA4444: 2158 - case DRM_FORMAT_BGRA4444: 2159 - case DRM_FORMAT_XRGB1555: 2160 - case DRM_FORMAT_XBGR1555: 2161 - case DRM_FORMAT_RGBX5551: 2162 - case DRM_FORMAT_BGRX5551: 2163 - case DRM_FORMAT_ARGB1555: 2164 - case DRM_FORMAT_ABGR1555: 2165 - case DRM_FORMAT_RGBA5551: 2166 - case DRM_FORMAT_BGRA5551: 2167 - case DRM_FORMAT_RGB565: 2168 - case DRM_FORMAT_BGR565: 2169 - case DRM_FORMAT_RGB888: 2170 - case DRM_FORMAT_BGR888: 2171 - case DRM_FORMAT_XRGB8888: 2172 - case DRM_FORMAT_XBGR8888: 2173 - case DRM_FORMAT_RGBX8888: 2174 - case DRM_FORMAT_BGRX8888: 2175 - case DRM_FORMAT_ARGB8888: 2176 - case DRM_FORMAT_ABGR8888: 2177 - case DRM_FORMAT_RGBA8888: 2178 - case DRM_FORMAT_BGRA8888: 2179 - case DRM_FORMAT_XRGB2101010: 2180 - case DRM_FORMAT_XBGR2101010: 2181 - case DRM_FORMAT_RGBX1010102: 2182 - case DRM_FORMAT_BGRX1010102: 2183 - case DRM_FORMAT_ARGB2101010: 2184 - case DRM_FORMAT_ABGR2101010: 2185 - case DRM_FORMAT_RGBA1010102: 2186 - case DRM_FORMAT_BGRA1010102: 2187 - case DRM_FORMAT_YUYV: 2188 - case DRM_FORMAT_YVYU: 2189 - case DRM_FORMAT_UYVY: 2190 - case DRM_FORMAT_VYUY: 2191 - case DRM_FORMAT_AYUV: 2192 - case DRM_FORMAT_NV12: 2193 - case DRM_FORMAT_NV21: 2194 - case DRM_FORMAT_NV16: 2195 - case DRM_FORMAT_NV61: 2196 - case DRM_FORMAT_NV24: 2197 - case DRM_FORMAT_NV42: 2198 - case DRM_FORMAT_YUV410: 2199 - case DRM_FORMAT_YVU410: 2200 - case DRM_FORMAT_YUV411: 2201 - case DRM_FORMAT_YVU411: 2202 - case DRM_FORMAT_YUV420: 2203 - case DRM_FORMAT_YVU420: 2204 - case DRM_FORMAT_YUV422: 2205 - case DRM_FORMAT_YVU422: 2206 - case DRM_FORMAT_YUV444: 2207 - case DRM_FORMAT_YVU444: 2208 - return 0; 2209 - default: 2210 - DRM_DEBUG_KMS("invalid pixel format %s\n", 2211 - drm_get_format_name(r->pixel_format)); 2212 - return -EINVAL; 2213 - } 2214 - } 2215 - 2216 - static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) 2217 - { 2218 - int ret, hsub, vsub, num_planes, i; 2219 - 2220 - ret = format_check(r); 2221 - if (ret) { 2222 - DRM_DEBUG_KMS("bad framebuffer format %s\n", 2223 - drm_get_format_name(r->pixel_format)); 2224 - return ret; 2225 - } 2226 - 2227 - hsub = drm_format_horz_chroma_subsampling(r->pixel_format); 2228 - vsub = drm_format_vert_chroma_subsampling(r->pixel_format); 2229 - num_planes = drm_format_num_planes(r->pixel_format); 2230 - 2231 - if (r->width == 0 || r->width % hsub) { 2232 - DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width); 2233 - return -EINVAL; 2234 - } 2235 - 2236 - if (r->height == 0 || r->height % vsub) { 2237 - DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height); 2238 - return -EINVAL; 2239 - } 2240 - 2241 - for (i = 0; i < num_planes; i++) { 2242 - unsigned int width = r->width / (i != 0 ? hsub : 1); 2243 - unsigned int height = r->height / (i != 0 ? vsub : 1); 2244 - unsigned int cpp = drm_format_plane_cpp(r->pixel_format, i); 2245 - 2246 - if (!r->handles[i]) { 2247 - DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i); 2248 - return -EINVAL; 2249 - } 2250 - 2251 - if ((uint64_t) width * cpp > UINT_MAX) 2252 - return -ERANGE; 2253 - 2254 - if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX) 2255 - return -ERANGE; 2256 - 2257 - if (r->pitches[i] < width * cpp) { 2258 - DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i); 2259 - return -EINVAL; 2260 - } 2261 - 2262 - if (r->modifier[i] && !(r->flags & DRM_MODE_FB_MODIFIERS)) { 2263 - DRM_DEBUG_KMS("bad fb modifier %llu for plane %d\n", 2264 - r->modifier[i], i); 2265 - return -EINVAL; 2266 - } 2267 - 2268 - /* modifier specific checks: */ 2269 - switch (r->modifier[i]) { 2270 - case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: 2271 - /* NOTE: the pitch restriction may be lifted later if it turns 2272 - * out that no hw has this restriction: 2273 - */ 2274 - if (r->pixel_format != DRM_FORMAT_NV12 || 2275 - width % 128 || height % 32 || 2276 - r->pitches[i] % 128) { 2277 - DRM_DEBUG_KMS("bad modifier data for plane %d\n", i); 2278 - return -EINVAL; 2279 - } 2280 - break; 2281 - 2282 - default: 2283 - break; 2284 - } 2285 - } 2286 - 2287 - for (i = num_planes; i < 4; i++) { 2288 - if (r->modifier[i]) { 2289 - DRM_DEBUG_KMS("non-zero modifier for unused plane %d\n", i); 2290 - return -EINVAL; 2291 - } 2292 - 2293 - /* Pre-FB_MODIFIERS userspace didn't clear the structs properly. */ 2294 - if (!(r->flags & DRM_MODE_FB_MODIFIERS)) 2295 - continue; 2296 - 2297 - if (r->handles[i]) { 2298 - DRM_DEBUG_KMS("buffer object handle for unused plane %d\n", i); 2299 - return -EINVAL; 2300 - } 2301 - 2302 - if (r->pitches[i]) { 2303 - DRM_DEBUG_KMS("non-zero pitch for unused plane %d\n", i); 2304 - return -EINVAL; 2305 - } 2306 - 2307 - if (r->offsets[i]) { 2308 - DRM_DEBUG_KMS("non-zero offset for unused plane %d\n", i); 2309 - return -EINVAL; 2310 - } 2311 - } 2312 - 2313 - return 0; 2314 - } 2315 - 2316 - static struct drm_framebuffer * 2317 - internal_framebuffer_create(struct drm_device *dev, 2318 - const struct drm_mode_fb_cmd2 *r, 2319 - struct drm_file *file_priv) 2320 - { 2321 - struct drm_mode_config *config = &dev->mode_config; 2322 - struct drm_framebuffer *fb; 2323 - int ret; 2324 - 2325 - if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) { 2326 - DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags); 2327 - return ERR_PTR(-EINVAL); 2328 - } 2329 - 2330 - if ((config->min_width > r->width) || (r->width > config->max_width)) { 2331 - DRM_DEBUG_KMS("bad framebuffer width %d, should be >= %d && <= %d\n", 2332 - r->width, config->min_width, config->max_width); 2333 - return ERR_PTR(-EINVAL); 2334 - } 2335 - if ((config->min_height > r->height) || (r->height > config->max_height)) { 2336 - DRM_DEBUG_KMS("bad framebuffer height %d, should be >= %d && <= %d\n", 2337 - r->height, config->min_height, config->max_height); 2338 - return ERR_PTR(-EINVAL); 2339 - } 2340 - 2341 - if (r->flags & DRM_MODE_FB_MODIFIERS && 2342 - !dev->mode_config.allow_fb_modifiers) { 2343 - DRM_DEBUG_KMS("driver does not support fb modifiers\n"); 2344 - return ERR_PTR(-EINVAL); 2345 - } 2346 - 2347 - ret = framebuffer_check(r); 2348 - if (ret) 2349 - return ERR_PTR(ret); 2350 - 2351 - fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); 2352 - if (IS_ERR(fb)) { 2353 - DRM_DEBUG_KMS("could not create framebuffer\n"); 2354 - return fb; 2355 - } 2356 - 2357 - return fb; 2358 - } 2359 - 2360 - /** 2361 - * drm_mode_addfb2 - add an FB to the graphics configuration 2362 - * @dev: drm device for the ioctl 2363 - * @data: data pointer for the ioctl 2364 - * @file_priv: drm file for the ioctl call 2365 - * 2366 - * Add a new FB to the specified CRTC, given a user request with format. This is 2367 - * the 2nd version of the addfb ioctl, which supports multi-planar framebuffers 2368 - * and uses fourcc codes as pixel format specifiers. 2369 - * 2370 - * Called by the user via ioctl. 2371 - * 2372 - * Returns: 2373 - * Zero on success, negative errno on failure. 2374 - */ 2375 - int drm_mode_addfb2(struct drm_device *dev, 2376 - void *data, struct drm_file *file_priv) 2377 - { 2378 - struct drm_mode_fb_cmd2 *r = data; 2379 - struct drm_framebuffer *fb; 2380 - 2381 - if (!drm_core_check_feature(dev, DRIVER_MODESET)) 2382 - return -EINVAL; 2383 - 2384 - fb = internal_framebuffer_create(dev, r, file_priv); 2385 - if (IS_ERR(fb)) 2386 - return PTR_ERR(fb); 2387 - 2388 - DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id); 2389 - r->fb_id = fb->base.id; 2390 - 2391 - /* Transfer ownership to the filp for reaping on close */ 2392 - mutex_lock(&file_priv->fbs_lock); 2393 - list_add(&fb->filp_head, &file_priv->fbs); 2394 - mutex_unlock(&file_priv->fbs_lock); 2395 - 2396 - return 0; 2397 - } 2398 - 2399 - struct drm_mode_rmfb_work { 2400 - struct work_struct work; 2401 - struct list_head fbs; 2402 - }; 2403 - 2404 - static void drm_mode_rmfb_work_fn(struct work_struct *w) 2405 - { 2406 - struct drm_mode_rmfb_work *arg = container_of(w, typeof(*arg), work); 2407 - 2408 - while (!list_empty(&arg->fbs)) { 2409 - struct drm_framebuffer *fb = 2410 - list_first_entry(&arg->fbs, typeof(*fb), filp_head); 2411 - 2412 - list_del_init(&fb->filp_head); 2413 - drm_framebuffer_remove(fb); 2414 - } 2415 - } 2416 - 2417 - /** 2418 - * drm_mode_rmfb - remove an FB from the configuration 2419 - * @dev: drm device for the ioctl 2420 - * @data: data pointer for the ioctl 2421 - * @file_priv: drm file for the ioctl call 2422 - * 2423 - * Remove the FB specified by the user. 2424 - * 2425 - * Called by the user via ioctl. 2426 - * 2427 - * Returns: 2428 - * Zero on success, negative errno on failure. 2429 - */ 2430 - int drm_mode_rmfb(struct drm_device *dev, 2431 - void *data, struct drm_file *file_priv) 2432 - { 2433 - struct drm_framebuffer *fb = NULL; 2434 - struct drm_framebuffer *fbl = NULL; 2435 - uint32_t *id = data; 2436 - int found = 0; 2437 - 2438 - if (!drm_core_check_feature(dev, DRIVER_MODESET)) 2439 - return -EINVAL; 2440 - 2441 - fb = drm_framebuffer_lookup(dev, *id); 2442 - if (!fb) 2443 - return -ENOENT; 2444 - 2445 - mutex_lock(&file_priv->fbs_lock); 2446 - list_for_each_entry(fbl, &file_priv->fbs, filp_head) 2447 - if (fb == fbl) 2448 - found = 1; 2449 - if (!found) { 2450 - mutex_unlock(&file_priv->fbs_lock); 2451 - goto fail_unref; 2452 - } 2453 - 2454 - list_del_init(&fb->filp_head); 2455 - mutex_unlock(&file_priv->fbs_lock); 2456 - 2457 - /* drop the reference we picked up in framebuffer lookup */ 2458 - drm_framebuffer_unreference(fb); 2459 - 2460 - /* 2461 - * we now own the reference that was stored in the fbs list 2462 - * 2463 - * drm_framebuffer_remove may fail with -EINTR on pending signals, 2464 - * so run this in a separate stack as there's no way to correctly 2465 - * handle this after the fb is already removed from the lookup table. 2466 - */ 2467 - if (drm_framebuffer_read_refcount(fb) > 1) { 2468 - struct drm_mode_rmfb_work arg; 2469 - 2470 - INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn); 2471 - INIT_LIST_HEAD(&arg.fbs); 2472 - list_add_tail(&fb->filp_head, &arg.fbs); 2473 - 2474 - schedule_work(&arg.work); 2475 - flush_work(&arg.work); 2476 - destroy_work_on_stack(&arg.work); 2477 - } else 2478 - drm_framebuffer_unreference(fb); 2479 - 2480 - return 0; 2481 - 2482 - fail_unref: 2483 - drm_framebuffer_unreference(fb); 2484 - return -ENOENT; 2485 - } 2486 - 2487 - /** 2488 - * drm_mode_getfb - get FB info 2489 - * @dev: drm device for the ioctl 2490 - * @data: data pointer for the ioctl 2491 - * @file_priv: drm file for the ioctl call 2492 - * 2493 - * Lookup the FB given its ID and return info about it. 2494 - * 2495 - * Called by the user via ioctl. 2496 - * 2497 - * Returns: 2498 - * Zero on success, negative errno on failure. 2499 - */ 2500 - int drm_mode_getfb(struct drm_device *dev, 2501 - void *data, struct drm_file *file_priv) 2502 - { 2503 - struct drm_mode_fb_cmd *r = data; 2504 - struct drm_framebuffer *fb; 2505 - int ret; 2506 - 2507 - if (!drm_core_check_feature(dev, DRIVER_MODESET)) 2508 - return -EINVAL; 2509 - 2510 - fb = drm_framebuffer_lookup(dev, r->fb_id); 2511 - if (!fb) 2512 - return -ENOENT; 2513 - 2514 - r->height = fb->height; 2515 - r->width = fb->width; 2516 - r->depth = fb->depth; 2517 - r->bpp = fb->bits_per_pixel; 2518 - r->pitch = fb->pitches[0]; 2519 - if (fb->funcs->create_handle) { 2520 - if (drm_is_current_master(file_priv) || capable(CAP_SYS_ADMIN) || 2521 - drm_is_control_client(file_priv)) { 2522 - ret = fb->funcs->create_handle(fb, file_priv, 2523 - &r->handle); 2524 - } else { 2525 - /* GET_FB() is an unprivileged ioctl so we must not 2526 - * return a buffer-handle to non-master processes! For 2527 - * backwards-compatibility reasons, we cannot make 2528 - * GET_FB() privileged, so just return an invalid handle 2529 - * for non-masters. */ 2530 - r->handle = 0; 2531 - ret = 0; 2532 - } 2533 - } else { 2534 - ret = -ENODEV; 2535 - } 2536 - 2537 - drm_framebuffer_unreference(fb); 2538 - 2539 - return ret; 2540 - } 2541 - 2542 - /** 2543 - * drm_mode_dirtyfb_ioctl - flush frontbuffer rendering on an FB 2544 - * @dev: drm device for the ioctl 2545 - * @data: data pointer for the ioctl 2546 - * @file_priv: drm file for the ioctl call 2547 - * 2548 - * Lookup the FB and flush out the damaged area supplied by userspace as a clip 2549 - * rectangle list. Generic userspace which does frontbuffer rendering must call 2550 - * this ioctl to flush out the changes on manual-update display outputs, e.g. 2551 - * usb display-link, mipi manual update panels or edp panel self refresh modes. 2552 - * 2553 - * Modesetting drivers which always update the frontbuffer do not need to 2554 - * implement the corresponding ->dirty framebuffer callback. 2555 - * 2556 - * Called by the user via ioctl. 2557 - * 2558 - * Returns: 2559 - * Zero on success, negative errno on failure. 2560 - */ 2561 - int drm_mode_dirtyfb_ioctl(struct drm_device *dev, 2562 - void *data, struct drm_file *file_priv) 2563 - { 2564 - struct drm_clip_rect __user *clips_ptr; 2565 - struct drm_clip_rect *clips = NULL; 2566 - struct drm_mode_fb_dirty_cmd *r = data; 2567 - struct drm_framebuffer *fb; 2568 - unsigned flags; 2569 - int num_clips; 2570 - int ret; 2571 - 2572 - if (!drm_core_check_feature(dev, DRIVER_MODESET)) 2573 - return -EINVAL; 2574 - 2575 - fb = drm_framebuffer_lookup(dev, r->fb_id); 2576 - if (!fb) 2577 - return -ENOENT; 2578 - 2579 - num_clips = r->num_clips; 2580 - clips_ptr = (struct drm_clip_rect __user *)(unsigned long)r->clips_ptr; 2581 - 2582 - if (!num_clips != !clips_ptr) { 2583 - ret = -EINVAL; 2584 - goto out_err1; 2585 - } 2586 - 2587 - flags = DRM_MODE_FB_DIRTY_FLAGS & r->flags; 2588 - 2589 - /* If userspace annotates copy, clips must come in pairs */ 2590 - if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY && (num_clips % 2)) { 2591 - ret = -EINVAL; 2592 - goto out_err1; 2593 - } 2594 - 2595 - if (num_clips && clips_ptr) { 2596 - if (num_clips < 0 || num_clips > DRM_MODE_FB_DIRTY_MAX_CLIPS) { 2597 - ret = -EINVAL; 2598 - goto out_err1; 2599 - } 2600 - clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL); 2601 - if (!clips) { 2602 - ret = -ENOMEM; 2603 - goto out_err1; 2604 - } 2605 - 2606 - ret = copy_from_user(clips, clips_ptr, 2607 - num_clips * sizeof(*clips)); 2608 - if (ret) { 2609 - ret = -EFAULT; 2610 - goto out_err2; 2611 - } 2612 - } 2613 - 2614 - if (fb->funcs->dirty) { 2615 - ret = fb->funcs->dirty(fb, file_priv, flags, r->color, 2616 - clips, num_clips); 2617 - } else { 2618 - ret = -ENOSYS; 2619 - } 2620 - 2621 - out_err2: 2622 - kfree(clips); 2623 - out_err1: 2624 - drm_framebuffer_unreference(fb); 2625 - 2626 - return ret; 2627 - } 2628 - 2629 - /** 2630 - * drm_fb_release - remove and free the FBs on this file 2631 - * @priv: drm file for the ioctl 2632 - * 2633 - * Destroy all the FBs associated with @filp. 2634 - * 2635 - * Called by the user via ioctl. 2636 - * 2637 - * Returns: 2638 - * Zero on success, negative errno on failure. 2639 - */ 2640 - void drm_fb_release(struct drm_file *priv) 2641 - { 2642 - struct drm_framebuffer *fb, *tfb; 2643 - struct drm_mode_rmfb_work arg; 2644 - 2645 - INIT_LIST_HEAD(&arg.fbs); 2646 - 2647 - /* 2648 - * When the file gets released that means no one else can access the fb 2649 - * list any more, so no need to grab fpriv->fbs_lock. And we need to 2650 - * avoid upsetting lockdep since the universal cursor code adds a 2651 - * framebuffer while holding mutex locks. 2652 - * 2653 - * Note that a real deadlock between fpriv->fbs_lock and the modeset 2654 - * locks is impossible here since no one else but this function can get 2655 - * at it any more. 2656 - */ 2657 - list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { 2658 - if (drm_framebuffer_read_refcount(fb) > 1) { 2659 - list_move_tail(&fb->filp_head, &arg.fbs); 2660 - } else { 2661 - list_del_init(&fb->filp_head); 2662 - 2663 - /* This drops the fpriv->fbs reference. */ 2664 - drm_framebuffer_unreference(fb); 2665 - } 2666 - } 2667 - 2668 - if (!list_empty(&arg.fbs)) { 2669 - INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn); 2670 - 2671 - schedule_work(&arg.work); 2672 - flush_work(&arg.work); 2673 - destroy_work_on_stack(&arg.work); 2674 - } 2675 - } 2676 3240 2677 3241 static bool drm_property_type_valid(struct drm_property *property) 2678 3242 { ··· 2814 4522 struct drm_mode_object *obj; 2815 4523 struct drm_property_blob *blob = NULL; 2816 4524 2817 - obj = _object_find(dev, id, DRM_MODE_OBJECT_BLOB); 4525 + obj = __drm_mode_object_find(dev, id, DRM_MODE_OBJECT_BLOB); 2818 4526 if (obj) 2819 4527 blob = obj_to_blob(obj); 2820 4528 return blob; ··· 2851 4559 * a completely atomic update. The access to path_blob_ptr is protected by the 2852 4560 * caller holding a lock on the connector. 2853 4561 */ 2854 - static int drm_property_replace_global_blob(struct drm_device *dev, 2855 - struct drm_property_blob **replace, 2856 - size_t length, 2857 - const void *data, 2858 - struct drm_mode_object *obj_holds_id, 2859 - struct drm_property *prop_holds_id) 4562 + int drm_property_replace_global_blob(struct drm_device *dev, 4563 + struct drm_property_blob **replace, 4564 + size_t length, 4565 + const void *data, 4566 + struct drm_mode_object *obj_holds_id, 4567 + struct drm_property *prop_holds_id) 2860 4568 { 2861 4569 struct drm_property_blob *new_blob = NULL; 2862 4570 struct drm_property_blob *old_blob = NULL; ··· 2895 4603 drm_property_unreference_blob(new_blob); 2896 4604 return ret; 2897 4605 } 4606 + EXPORT_SYMBOL(drm_property_replace_global_blob); 2898 4607 2899 4608 /** 2900 4609 * drm_mode_getblob_ioctl - get the contents of a blob property value ··· 3051 4758 return ret; 3052 4759 } 3053 4760 3054 - /** 3055 - * drm_mode_connector_set_path_property - set tile property on connector 3056 - * @connector: connector to set property on. 3057 - * @path: path to use for property; must not be NULL. 3058 - * 3059 - * This creates a property to expose to userspace to specify a 3060 - * connector path. This is mainly used for DisplayPort MST where 3061 - * connectors have a topology and we want to allow userspace to give 3062 - * them more meaningful names. 3063 - * 3064 - * Returns: 3065 - * Zero on success, negative errno on failure. 3066 - */ 3067 - int drm_mode_connector_set_path_property(struct drm_connector *connector, 3068 - const char *path) 3069 - { 3070 - struct drm_device *dev = connector->dev; 3071 - int ret; 3072 - 3073 - ret = drm_property_replace_global_blob(dev, 3074 - &connector->path_blob_ptr, 3075 - strlen(path) + 1, 3076 - path, 3077 - &connector->base, 3078 - dev->mode_config.path_property); 3079 - return ret; 3080 - } 3081 - EXPORT_SYMBOL(drm_mode_connector_set_path_property); 3082 - 3083 - /** 3084 - * drm_mode_connector_set_tile_property - set tile property on connector 3085 - * @connector: connector to set property on. 3086 - * 3087 - * This looks up the tile information for a connector, and creates a 3088 - * property for userspace to parse if it exists. The property is of 3089 - * the form of 8 integers using ':' as a separator. 3090 - * 3091 - * Returns: 3092 - * Zero on success, errno on failure. 3093 - */ 3094 - int drm_mode_connector_set_tile_property(struct drm_connector *connector) 3095 - { 3096 - struct drm_device *dev = connector->dev; 3097 - char tile[256]; 3098 - int ret; 3099 - 3100 - if (!connector->has_tile) { 3101 - ret = drm_property_replace_global_blob(dev, 3102 - &connector->tile_blob_ptr, 3103 - 0, 3104 - NULL, 3105 - &connector->base, 3106 - dev->mode_config.tile_property); 3107 - return ret; 3108 - } 3109 - 3110 - snprintf(tile, 256, "%d:%d:%d:%d:%d:%d:%d:%d", 3111 - connector->tile_group->id, connector->tile_is_single_monitor, 3112 - connector->num_h_tile, connector->num_v_tile, 3113 - connector->tile_h_loc, connector->tile_v_loc, 3114 - connector->tile_h_size, connector->tile_v_size); 3115 - 3116 - ret = drm_property_replace_global_blob(dev, 3117 - &connector->tile_blob_ptr, 3118 - strlen(tile) + 1, 3119 - tile, 3120 - &connector->base, 3121 - dev->mode_config.tile_property); 3122 - return ret; 3123 - } 3124 - EXPORT_SYMBOL(drm_mode_connector_set_tile_property); 3125 - 3126 - /** 3127 - * drm_mode_connector_update_edid_property - update the edid property of a connector 3128 - * @connector: drm connector 3129 - * @edid: new value of the edid property 3130 - * 3131 - * This function creates a new blob modeset object and assigns its id to the 3132 - * connector's edid property. 3133 - * 3134 - * Returns: 3135 - * Zero on success, negative errno on failure. 3136 - */ 3137 - int drm_mode_connector_update_edid_property(struct drm_connector *connector, 3138 - const struct edid *edid) 3139 - { 3140 - struct drm_device *dev = connector->dev; 3141 - size_t size = 0; 3142 - int ret; 3143 - 3144 - /* ignore requests to set edid when overridden */ 3145 - if (connector->override_edid) 3146 - return 0; 3147 - 3148 - if (edid) 3149 - size = EDID_LENGTH * (1 + edid->extensions); 3150 - 3151 - ret = drm_property_replace_global_blob(dev, 3152 - &connector->edid_blob_ptr, 3153 - size, 3154 - edid, 3155 - &connector->base, 3156 - dev->mode_config.edid_property); 3157 - return ret; 3158 - } 3159 - EXPORT_SYMBOL(drm_mode_connector_update_edid_property); 3160 - 3161 4761 /* Some properties could refer to dynamic refcnt'd objects, or things that 3162 4762 * need special locking to handle lifetime issues (ie. to ensure the prop 3163 4763 * value doesn't become invalid part way through the property update due to ··· 3104 4918 if (value == 0) 3105 4919 return true; 3106 4920 3107 - *ref = _object_find(property->dev, value, property->values[0]); 4921 + *ref = __drm_mode_object_find(property->dev, value, 4922 + property->values[0]); 3108 4923 return *ref != NULL; 3109 4924 } 3110 4925 ··· 3125 4938 drm_mode_object_unreference(ref); 3126 4939 } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) 3127 4940 drm_property_unreference_blob(obj_to_blob(ref)); 3128 - } 3129 - 3130 - /** 3131 - * drm_mode_connector_property_set_ioctl - set the current value of a connector property 3132 - * @dev: DRM device 3133 - * @data: ioctl data 3134 - * @file_priv: DRM file info 3135 - * 3136 - * This function sets the current value for a connectors's property. It also 3137 - * calls into a driver's ->set_property callback to update the hardware state 3138 - * 3139 - * Called by the user via ioctl. 3140 - * 3141 - * Returns: 3142 - * Zero on success, negative errno on failure. 3143 - */ 3144 - int drm_mode_connector_property_set_ioctl(struct drm_device *dev, 3145 - void *data, struct drm_file *file_priv) 3146 - { 3147 - struct drm_mode_connector_set_property *conn_set_prop = data; 3148 - struct drm_mode_obj_set_property obj_set_prop = { 3149 - .value = conn_set_prop->value, 3150 - .prop_id = conn_set_prop->prop_id, 3151 - .obj_id = conn_set_prop->connector_id, 3152 - .obj_type = DRM_MODE_OBJECT_CONNECTOR 3153 - }; 3154 - 3155 - /* It does all the locking and checking we need */ 3156 - return drm_mode_obj_set_property_ioctl(dev, &obj_set_prop, file_priv); 3157 - } 3158 - 3159 - static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj, 3160 - struct drm_property *property, 3161 - uint64_t value) 3162 - { 3163 - int ret = -EINVAL; 3164 - struct drm_connector *connector = obj_to_connector(obj); 3165 - 3166 - /* Do DPMS ourselves */ 3167 - if (property == connector->dev->mode_config.dpms_property) { 3168 - ret = (*connector->funcs->dpms)(connector, (int)value); 3169 - } else if (connector->funcs->set_property) 3170 - ret = connector->funcs->set_property(connector, property, value); 3171 - 3172 - /* store the property value if successful */ 3173 - if (!ret) 3174 - drm_object_property_set_value(&connector->base, property, value); 3175 - return ret; 3176 4941 } 3177 4942 3178 4943 static int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj, ··· 3208 5069 goto out_unref; 3209 5070 } 3210 5071 3211 - ret = get_properties(obj, file_priv->atomic, 5072 + ret = drm_mode_object_get_properties(obj, file_priv->atomic, 3212 5073 (uint32_t __user *)(unsigned long)(arg->props_ptr), 3213 5074 (uint64_t __user *)(unsigned long)(arg->prop_values_ptr), 3214 5075 &arg->count_props); ··· 3220 5081 return ret; 3221 5082 } 3222 5083 3223 - /** 3224 - * drm_mode_obj_set_property_ioctl - set the current value of an object's property 3225 - * @dev: DRM device 3226 - * @data: ioctl data 3227 - * @file_priv: DRM file info 3228 - * 3229 - * This function sets the current value for an object's property. It also calls 3230 - * into a driver's ->set_property callback to update the hardware state. 3231 - * Compared to the connector specific ioctl this one is extended to also work on 3232 - * crtc and plane objects. 3233 - * 3234 - * Called by the user via ioctl. 3235 - * 3236 - * Returns: 3237 - * Zero on success, negative errno on failure. 3238 - */ 3239 5084 int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, 3240 5085 struct drm_file *file_priv) 3241 5086 { ··· 3283 5160 drm_modeset_unlock_all(dev); 3284 5161 return ret; 3285 5162 } 3286 - 3287 - /** 3288 - * drm_mode_connector_attach_encoder - attach a connector to an encoder 3289 - * @connector: connector to attach 3290 - * @encoder: encoder to attach @connector to 3291 - * 3292 - * This function links up a connector to an encoder. Note that the routing 3293 - * restrictions between encoders and crtcs are exposed to userspace through the 3294 - * possible_clones and possible_crtcs bitmasks. 3295 - * 3296 - * Returns: 3297 - * Zero on success, negative errno on failure. 3298 - */ 3299 - int drm_mode_connector_attach_encoder(struct drm_connector *connector, 3300 - struct drm_encoder *encoder) 3301 - { 3302 - int i; 3303 - 3304 - /* 3305 - * In the past, drivers have attempted to model the static association 3306 - * of connector to encoder in simple connector/encoder devices using a 3307 - * direct assignment of connector->encoder = encoder. This connection 3308 - * is a logical one and the responsibility of the core, so drivers are 3309 - * expected not to mess with this. 3310 - * 3311 - * Note that the error return should've been enough here, but a large 3312 - * majority of drivers ignores the return value, so add in a big WARN 3313 - * to get people's attention. 3314 - */ 3315 - if (WARN_ON(connector->encoder)) 3316 - return -EINVAL; 3317 - 3318 - for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 3319 - if (connector->encoder_ids[i] == 0) { 3320 - connector->encoder_ids[i] = encoder->base.id; 3321 - return 0; 3322 - } 3323 - } 3324 - return -ENOMEM; 3325 - } 3326 - EXPORT_SYMBOL(drm_mode_connector_attach_encoder); 3327 5163 3328 5164 /** 3329 5165 * drm_mode_crtc_set_gamma_size - set the gamma table size
-56
drivers/gpu/drm/drm_crtc_helper.c
··· 75 75 */ 76 76 77 77 /** 78 - * drm_helper_move_panel_connectors_to_head() - move panels to the front in the 79 - * connector list 80 - * @dev: drm device to operate on 81 - * 82 - * Some userspace presumes that the first connected connector is the main 83 - * display, where it's supposed to display e.g. the login screen. For 84 - * laptops, this should be the main panel. Use this function to sort all 85 - * (eDP/LVDS) panels to the front of the connector list, instead of 86 - * painstakingly trying to initialize them in the right order. 87 - */ 88 - void drm_helper_move_panel_connectors_to_head(struct drm_device *dev) 89 - { 90 - struct drm_connector *connector, *tmp; 91 - struct list_head panel_list; 92 - 93 - INIT_LIST_HEAD(&panel_list); 94 - 95 - list_for_each_entry_safe(connector, tmp, 96 - &dev->mode_config.connector_list, head) { 97 - if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS || 98 - connector->connector_type == DRM_MODE_CONNECTOR_eDP) 99 - list_move_tail(&connector->head, &panel_list); 100 - } 101 - 102 - list_splice(&panel_list, &dev->mode_config.connector_list); 103 - } 104 - EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head); 105 - 106 - /** 107 78 * drm_helper_encoder_in_use - check if a given encoder is in use 108 79 * @encoder: encoder to check 109 80 * ··· 882 911 return 0; 883 912 } 884 913 EXPORT_SYMBOL(drm_helper_connector_dpms); 885 - 886 - /** 887 - * drm_helper_mode_fill_fb_struct - fill out framebuffer metadata 888 - * @fb: drm_framebuffer object to fill out 889 - * @mode_cmd: metadata from the userspace fb creation request 890 - * 891 - * This helper can be used in a drivers fb_create callback to pre-fill the fb's 892 - * metadata fields. 893 - */ 894 - void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, 895 - const struct drm_mode_fb_cmd2 *mode_cmd) 896 - { 897 - int i; 898 - 899 - fb->width = mode_cmd->width; 900 - fb->height = mode_cmd->height; 901 - for (i = 0; i < 4; i++) { 902 - fb->pitches[i] = mode_cmd->pitches[i]; 903 - fb->offsets[i] = mode_cmd->offsets[i]; 904 - fb->modifier[i] = mode_cmd->modifier[i]; 905 - } 906 - drm_fb_get_bpp_depth(mode_cmd->pixel_format, &fb->depth, 907 - &fb->bits_per_pixel); 908 - fb->pixel_format = mode_cmd->pixel_format; 909 - fb->flags = mode_cmd->flags; 910 - } 911 - EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct); 912 914 913 915 /** 914 916 * drm_helper_resume_force_mode - force-restore mode setting configuration
+50 -20
drivers/gpu/drm/drm_crtc_internal.h
··· 33 33 34 34 35 35 /* drm_crtc.c */ 36 - void drm_connector_ida_init(void); 37 - void drm_connector_ida_destroy(void); 36 + int drm_mode_object_get_reg(struct drm_device *dev, 37 + struct drm_mode_object *obj, 38 + uint32_t obj_type, 39 + bool register_obj, 40 + void (*obj_free_cb)(struct kref *kref)); 41 + void drm_mode_object_register(struct drm_device *dev, 42 + struct drm_mode_object *obj); 38 43 int drm_mode_object_get(struct drm_device *dev, 39 44 struct drm_mode_object *obj, uint32_t obj_type); 45 + struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev, 46 + uint32_t id, uint32_t type); 40 47 void drm_mode_object_unregister(struct drm_device *dev, 41 48 struct drm_mode_object *object); 49 + int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, 50 + uint32_t __user *prop_ptr, 51 + uint64_t __user *prop_values, 52 + uint32_t *arg_count_props); 42 53 bool drm_property_change_valid_get(struct drm_property *property, 43 54 uint64_t value, 44 55 struct drm_mode_object **ref); ··· 75 64 int drm_mode_destroy_dumb_ioctl(struct drm_device *dev, 76 65 void *data, struct drm_file *file_priv); 77 66 78 - /* framebuffer IOCTLs */ 79 - extern int drm_mode_addfb(struct drm_device *dev, 80 - void *data, struct drm_file *file_priv); 81 - extern int drm_mode_addfb2(struct drm_device *dev, 82 - void *data, struct drm_file *file_priv); 83 - int drm_mode_rmfb(struct drm_device *dev, 84 - void *data, struct drm_file *file_priv); 85 - int drm_mode_getfb(struct drm_device *dev, 86 - void *data, struct drm_file *file_priv); 87 - int drm_mode_dirtyfb_ioctl(struct drm_device *dev, 88 - void *data, struct drm_file *file_priv); 89 - 90 67 /* IOCTLs */ 91 68 int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, 92 69 struct drm_file *file_priv); ··· 87 88 struct drm_file *file_priv); 88 89 int drm_mode_getcrtc(struct drm_device *dev, 89 90 void *data, struct drm_file *file_priv); 90 - int drm_mode_getconnector(struct drm_device *dev, 91 - void *data, struct drm_file *file_priv); 92 91 int drm_mode_setcrtc(struct drm_device *dev, 93 92 void *data, struct drm_file *file_priv); 94 93 int drm_mode_getplane(struct drm_device *dev, ··· 105 108 void *data, struct drm_file *file_priv); 106 109 int drm_mode_destroyblob_ioctl(struct drm_device *dev, 107 110 void *data, struct drm_file *file_priv); 108 - int drm_mode_connector_property_set_ioctl(struct drm_device *dev, 109 - void *data, struct drm_file *file_priv); 110 111 int drm_mode_getencoder(struct drm_device *dev, 111 112 void *data, struct drm_file *file_priv); 112 113 int drm_mode_gamma_get_ioctl(struct drm_device *dev, ··· 114 119 115 120 int drm_mode_page_flip_ioctl(struct drm_device *dev, 116 121 void *data, struct drm_file *file_priv); 122 + 123 + /* drm_connector.c */ 124 + void drm_connector_ida_init(void); 125 + void drm_connector_ida_destroy(void); 126 + void drm_connector_unregister_all(struct drm_device *dev); 127 + int drm_connector_register_all(struct drm_device *dev); 128 + int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj, 129 + struct drm_property *property, 130 + uint64_t value); 131 + int drm_connector_create_standard_properties(struct drm_device *dev); 132 + 133 + /* IOCTL */ 134 + int drm_mode_connector_property_set_ioctl(struct drm_device *dev, 135 + void *data, struct drm_file *file_priv); 136 + int drm_mode_getconnector(struct drm_device *dev, 137 + void *data, struct drm_file *file_priv); 138 + 139 + /* drm_framebuffer.c */ 140 + struct drm_framebuffer * 141 + drm_internal_framebuffer_create(struct drm_device *dev, 142 + const struct drm_mode_fb_cmd2 *r, 143 + struct drm_file *file_priv); 144 + void drm_framebuffer_free(struct kref *kref); 145 + 146 + /* IOCTL */ 147 + int drm_mode_addfb(struct drm_device *dev, 148 + void *data, struct drm_file *file_priv); 149 + int drm_mode_addfb2(struct drm_device *dev, 150 + void *data, struct drm_file *file_priv); 151 + int drm_mode_rmfb(struct drm_device *dev, 152 + void *data, struct drm_file *file_priv); 153 + int drm_mode_getfb(struct drm_device *dev, 154 + void *data, struct drm_file *file_priv); 155 + int drm_mode_dirtyfb_ioctl(struct drm_device *dev, 156 + void *data, struct drm_file *file_priv); 117 157 118 158 /* drm_atomic.c */ 119 159 int drm_atomic_get_property(struct drm_mode_object *obj, ··· 160 130 void drm_modeset_unregister_all(struct drm_device *dev); 161 131 162 132 /* drm_blend.c */ 163 - int drm_atomic_helper_normalize_zpos(struct drm_device *dev, 164 - struct drm_atomic_state *state); 133 + int drm_atomic_normalize_zpos(struct drm_device *dev, 134 + struct drm_atomic_state *state);
+3 -16
drivers/gpu/drm/drm_dp_aux_dev.c
··· 36 36 #include <drm/drm_crtc.h> 37 37 #include <drm/drmP.h> 38 38 39 + #include "drm_crtc_helper_internal.h" 40 + 39 41 struct drm_dp_aux_dev { 40 42 unsigned index; 41 43 struct drm_dp_aux *aux; ··· 285 283 schedule(); 286 284 return 0; 287 285 } 288 - /** 289 - * drm_dp_aux_unregister_devnode() - unregister a devnode for this aux channel 290 - * @aux: DisplayPort AUX channel 291 - * 292 - * Returns 0 on success or a negative error code on failure. 293 - */ 286 + 294 287 void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux) 295 288 { 296 289 struct drm_dp_aux_dev *aux_dev; ··· 311 314 DRM_DEBUG("drm_dp_aux_dev: aux [%s] unregistering\n", aux->name); 312 315 kref_put(&aux_dev->refcount, release_drm_dp_aux_dev); 313 316 } 314 - EXPORT_SYMBOL(drm_dp_aux_unregister_devnode); 315 317 316 - /** 317 - * drm_dp_aux_register_devnode() - register a devnode for this aux channel 318 - * @aux: DisplayPort AUX channel 319 - * 320 - * Returns 0 on success or a negative error code on failure. 321 - */ 322 318 int drm_dp_aux_register_devnode(struct drm_dp_aux *aux) 323 319 { 324 320 struct drm_dp_aux_dev *aux_dev; ··· 337 347 drm_dp_aux_unregister_devnode(aux); 338 348 return res; 339 349 } 340 - EXPORT_SYMBOL(drm_dp_aux_register_devnode); 341 350 342 351 int drm_dp_aux_dev_init(void) 343 352 { ··· 358 369 class_destroy(drm_dp_aux_dev_class); 359 370 return res; 360 371 } 361 - EXPORT_SYMBOL(drm_dp_aux_dev_init); 362 372 363 373 void drm_dp_aux_dev_exit(void) 364 374 { 365 375 unregister_chrdev(drm_dev_major, "aux"); 366 376 class_destroy(drm_dp_aux_dev_class); 367 377 } 368 - EXPORT_SYMBOL(drm_dp_aux_dev_exit);
+2 -1
drivers/gpu/drm/drm_dp_helper.c
··· 28 28 #include <linux/sched.h> 29 29 #include <linux/i2c.h> 30 30 #include <drm/drm_dp_helper.h> 31 - #include <drm/drm_dp_aux_dev.h> 32 31 #include <drm/drmP.h> 32 + 33 + #include "drm_crtc_helper_internal.h" 33 34 34 35 /** 35 36 * DOC: dp helpers
+33 -19
drivers/gpu/drm/drm_drv.c
··· 63 63 64 64 static struct dentry *drm_debugfs_root; 65 65 66 - void drm_err(const char *format, ...) 66 + #define DRM_PRINTK_FMT "[" DRM_NAME ":%s]%s %pV" 67 + 68 + void drm_dev_printk(const struct device *dev, const char *level, 69 + unsigned int category, const char *function_name, 70 + const char *prefix, const char *format, ...) 67 71 { 68 72 struct va_format vaf; 69 73 va_list args; 70 74 71 - va_start(args, format); 72 - 73 - vaf.fmt = format; 74 - vaf.va = &args; 75 - 76 - printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV", 77 - __builtin_return_address(0), &vaf); 78 - 79 - va_end(args); 80 - } 81 - EXPORT_SYMBOL(drm_err); 82 - 83 - void drm_ut_debug_printk(const char *function_name, const char *format, ...) 84 - { 85 - struct va_format vaf; 86 - va_list args; 75 + if (category != DRM_UT_NONE && !(drm_debug & category)) 76 + return; 87 77 88 78 va_start(args, format); 89 79 vaf.fmt = format; 90 80 vaf.va = &args; 91 81 92 - printk(KERN_DEBUG "[" DRM_NAME ":%s] %pV", function_name, &vaf); 82 + if (dev) 83 + dev_printk(level, dev, DRM_PRINTK_FMT, function_name, prefix, 84 + &vaf); 85 + else 86 + printk("%s" DRM_PRINTK_FMT, level, function_name, prefix, &vaf); 93 87 94 88 va_end(args); 95 89 } 96 - EXPORT_SYMBOL(drm_ut_debug_printk); 90 + EXPORT_SYMBOL(drm_dev_printk); 91 + 92 + void drm_printk(const char *level, unsigned int category, 93 + const char *function_name, const char *prefix, 94 + const char *format, ...) 95 + { 96 + struct va_format vaf; 97 + va_list args; 98 + 99 + if (category != DRM_UT_NONE && !(drm_debug & category)) 100 + return; 101 + 102 + va_start(args, format); 103 + vaf.fmt = format; 104 + vaf.va = &args; 105 + 106 + printk("%s" DRM_PRINTK_FMT, level, function_name, prefix, &vaf); 107 + 108 + va_end(args); 109 + } 110 + EXPORT_SYMBOL(drm_printk); 97 111 98 112 /* 99 113 * DRM Minors
+5 -20
drivers/gpu/drm/drm_edid.c
··· 991 991 .vrefresh = 120, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, 992 992 /* 64 - 1920x1080@100Hz */ 993 993 { DRM_MODE("1920x1080", DRM_MODE_TYPE_DRIVER, 297000, 1920, 2448, 994 - 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, 994 + 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, 995 995 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC), 996 996 .vrefresh = 100, .picture_aspect_ratio = HDMI_PICTURE_ASPECT_16_9, }, 997 997 }; ··· 3721 3721 } 3722 3722 EXPORT_SYMBOL(drm_rgb_quant_range_selectable); 3723 3723 3724 - /** 3725 - * drm_assign_hdmi_deep_color_info - detect whether monitor supports 3726 - * hdmi deep color modes and update drm_display_info if so. 3727 - * @edid: monitor EDID information 3728 - * @info: Updated with maximum supported deep color bpc and color format 3729 - * if deep color supported. 3730 - * @connector: DRM connector, used only for debug output 3731 - * 3724 + /* 3732 3725 * Parse the CEA extension according to CEA-861-B. 3733 3726 * Return true if HDMI deep color supported, false if not or unknown. 3734 3727 */ ··· 3815 3822 return false; 3816 3823 } 3817 3824 3818 - /** 3819 - * drm_add_display_info - pull display info out if present 3820 - * @edid: EDID data 3821 - * @info: display info (attached to connector) 3822 - * @connector: connector whose edid is used to build display info 3823 - * 3824 - * Grab any available display info and stuff it into the drm_display_info 3825 - * structure that's part of the connector. Useful for tracking bpp and 3826 - * color spaces. 3827 - */ 3828 3825 static void drm_add_display_info(struct edid *edid, 3829 3826 struct drm_display_info *info, 3830 3827 struct drm_connector *connector) ··· 4035 4052 * @connector: connector we're probing 4036 4053 * @edid: EDID data 4037 4054 * 4038 - * Add the specified modes to the connector's mode list. 4055 + * Add the specified modes to the connector's mode list. Also fills out the 4056 + * &drm_display_info structure in @connector with any information which can be 4057 + * derived from the edid. 4039 4058 * 4040 4059 * Return: The number of modes added or 0 if we couldn't find any. 4041 4060 */
+65 -5
drivers/gpu/drm/drm_fb_helper.c
··· 29 29 */ 30 30 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 31 31 32 + #include <linux/console.h> 32 33 #include <linux/kernel.h> 33 34 #include <linux/sysrq.h> 34 35 #include <linux/slab.h> ··· 618 617 kfree(helper->crtc_info); 619 618 } 620 619 620 + static void drm_fb_helper_resume_worker(struct work_struct *work) 621 + { 622 + struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper, 623 + resume_work); 624 + 625 + console_lock(); 626 + fb_set_suspend(helper->fbdev, 0); 627 + console_unlock(); 628 + } 629 + 621 630 static void drm_fb_helper_dirty_work(struct work_struct *work) 622 631 { 623 632 struct drm_fb_helper *helper = container_of(work, struct drm_fb_helper, ··· 659 648 { 660 649 INIT_LIST_HEAD(&helper->kernel_fb_list); 661 650 spin_lock_init(&helper->dirty_lock); 651 + INIT_WORK(&helper->resume_work, drm_fb_helper_resume_worker); 662 652 INIT_WORK(&helper->dirty_work, drm_fb_helper_dirty_work); 663 653 helper->dirty_clip.x1 = helper->dirty_clip.y1 = ~0; 664 654 helper->funcs = funcs; ··· 1035 1023 /** 1036 1024 * drm_fb_helper_set_suspend - wrapper around fb_set_suspend 1037 1025 * @fb_helper: driver-allocated fbdev helper 1038 - * @state: desired state, zero to resume, non-zero to suspend 1026 + * @suspend: whether to suspend or resume 1039 1027 * 1040 - * A wrapper around fb_set_suspend implemented by fbdev core 1028 + * A wrapper around fb_set_suspend implemented by fbdev core. 1029 + * Use drm_fb_helper_set_suspend_unlocked() if you don't need to take 1030 + * the lock yourself 1041 1031 */ 1042 - void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state) 1032 + void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend) 1043 1033 { 1044 1034 if (fb_helper && fb_helper->fbdev) 1045 - fb_set_suspend(fb_helper->fbdev, state); 1035 + fb_set_suspend(fb_helper->fbdev, suspend); 1046 1036 } 1047 1037 EXPORT_SYMBOL(drm_fb_helper_set_suspend); 1038 + 1039 + /** 1040 + * drm_fb_helper_set_suspend_unlocked - wrapper around fb_set_suspend that also 1041 + * takes the console lock 1042 + * @fb_helper: driver-allocated fbdev helper 1043 + * @suspend: whether to suspend or resume 1044 + * 1045 + * A wrapper around fb_set_suspend() that takes the console lock. If the lock 1046 + * isn't available on resume, a worker is tasked with waiting for the lock 1047 + * to become available. The console lock can be pretty contented on resume 1048 + * due to all the printk activity. 1049 + * 1050 + * This function can be called multiple times with the same state since 1051 + * &fb_info->state is checked to see if fbdev is running or not before locking. 1052 + * 1053 + * Use drm_fb_helper_set_suspend() if you need to take the lock yourself. 1054 + */ 1055 + void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper, 1056 + bool suspend) 1057 + { 1058 + if (!fb_helper || !fb_helper->fbdev) 1059 + return; 1060 + 1061 + /* make sure there's no pending/ongoing resume */ 1062 + flush_work(&fb_helper->resume_work); 1063 + 1064 + if (suspend) { 1065 + if (fb_helper->fbdev->state != FBINFO_STATE_RUNNING) 1066 + return; 1067 + 1068 + console_lock(); 1069 + 1070 + } else { 1071 + if (fb_helper->fbdev->state == FBINFO_STATE_RUNNING) 1072 + return; 1073 + 1074 + if (!console_trylock()) { 1075 + schedule_work(&fb_helper->resume_work); 1076 + return; 1077 + } 1078 + } 1079 + 1080 + fb_set_suspend(fb_helper->fbdev, suspend); 1081 + console_unlock(); 1082 + } 1083 + EXPORT_SYMBOL(drm_fb_helper_set_suspend_unlocked); 1048 1084 1049 1085 static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, 1050 1086 u16 blue, u16 regno, struct fb_info *info) ··· 2253 2193 * @fb_helper: the drm_fb_helper 2254 2194 * 2255 2195 * Scan the connectors attached to the fb_helper and try to put together a 2256 - * setup after *notification of a change in output configuration. 2196 + * setup after notification of a change in output configuration. 2257 2197 * 2258 2198 * Called at runtime, takes the mode config locks to be able to check/change the 2259 2199 * modeset configuration. Must be run from process context (which usually means
+10 -9
drivers/gpu/drm/drm_fourcc.c
··· 39 39 * drm_get_format_name - return a string for drm fourcc format 40 40 * @format: format to compute name of 41 41 * 42 - * Note that the buffer used by this function is globally shared and owned by 43 - * the function itself. 44 - * 45 - * FIXME: This isn't really multithreading safe. 42 + * Note that the buffer returned by this function is owned by the caller 43 + * and will need to be freed using kfree(). 46 44 */ 47 - const char *drm_get_format_name(uint32_t format) 45 + char *drm_get_format_name(uint32_t format) 48 46 { 49 - static char buf[32]; 47 + char *buf = kmalloc(32, GFP_KERNEL); 50 48 51 - snprintf(buf, sizeof(buf), 49 + snprintf(buf, 32, 52 50 "%c%c%c%c %s-endian (0x%08x)", 53 51 printable_char(format & 0xff), 54 52 printable_char((format >> 8) & 0xff), ··· 71 73 void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, 72 74 int *bpp) 73 75 { 76 + char *format_name; 77 + 74 78 switch (format) { 75 79 case DRM_FORMAT_C8: 76 80 case DRM_FORMAT_RGB332: ··· 127 127 *bpp = 32; 128 128 break; 129 129 default: 130 - DRM_DEBUG_KMS("unsupported pixel format %s\n", 131 - drm_get_format_name(format)); 130 + format_name = drm_get_format_name(format); 131 + DRM_DEBUG_KMS("unsupported pixel format %s\n", format_name); 132 + kfree(format_name); 132 133 *depth = 0; 133 134 *bpp = 0; 134 135 break;
+831
drivers/gpu/drm/drm_framebuffer.c
··· 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 <linux/export.h> 24 + #include <drm/drmP.h> 25 + #include <drm/drm_auth.h> 26 + #include <drm/drm_framebuffer.h> 27 + 28 + #include "drm_crtc_internal.h" 29 + 30 + /** 31 + * DOC: overview 32 + * 33 + * Frame buffers are abstract memory objects that provide a source of pixels to 34 + * scanout to a CRTC. Applications explicitly request the creation of frame 35 + * buffers through the DRM_IOCTL_MODE_ADDFB(2) ioctls and receive an opaque 36 + * handle that can be passed to the KMS CRTC control, plane configuration and 37 + * page flip functions. 38 + * 39 + * Frame buffers rely on the underlying memory manager for allocating backing 40 + * storage. When creating a frame buffer applications pass a memory handle 41 + * (or a list of memory handles for multi-planar formats) through the 42 + * struct &drm_mode_fb_cmd2 argument. For drivers using GEM as their userspace 43 + * buffer management interface this would be a GEM handle. Drivers are however 44 + * free to use their own backing storage object handles, e.g. vmwgfx directly 45 + * exposes special TTM handles to userspace and so expects TTM handles in the 46 + * create ioctl and not GEM handles. 47 + * 48 + * Framebuffers are tracked with struct &drm_framebuffer. They are published 49 + * using drm_framebuffer_init() - after calling that function userspace can use 50 + * and access the framebuffer object. The helper function 51 + * drm_helper_mode_fill_fb_struct() can be used to pre-fill the required 52 + * metadata fields. 53 + * 54 + * The lifetime of a drm framebuffer is controlled with a reference count, 55 + * drivers can grab additional references with drm_framebuffer_reference() and 56 + * drop them again with drm_framebuffer_unreference(). For driver-private 57 + * framebuffers for which the last reference is never dropped (e.g. for the 58 + * fbdev framebuffer when the struct struct &drm_framebuffer is embedded into 59 + * the fbdev helper struct) drivers can manually clean up a framebuffer at 60 + * module unload time with drm_framebuffer_unregister_private(). But doing this 61 + * is not recommended, and it's better to have a normal free-standing struct 62 + * &drm_framebuffer. 63 + */ 64 + 65 + /** 66 + * drm_mode_addfb - add an FB to the graphics configuration 67 + * @dev: drm device for the ioctl 68 + * @data: data pointer for the ioctl 69 + * @file_priv: drm file for the ioctl call 70 + * 71 + * Add a new FB to the specified CRTC, given a user request. This is the 72 + * original addfb ioctl which only supported RGB formats. 73 + * 74 + * Called by the user via ioctl. 75 + * 76 + * Returns: 77 + * Zero on success, negative errno on failure. 78 + */ 79 + int drm_mode_addfb(struct drm_device *dev, 80 + void *data, struct drm_file *file_priv) 81 + { 82 + struct drm_mode_fb_cmd *or = data; 83 + struct drm_mode_fb_cmd2 r = {}; 84 + int ret; 85 + 86 + /* convert to new format and call new ioctl */ 87 + r.fb_id = or->fb_id; 88 + r.width = or->width; 89 + r.height = or->height; 90 + r.pitches[0] = or->pitch; 91 + r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth); 92 + r.handles[0] = or->handle; 93 + 94 + ret = drm_mode_addfb2(dev, &r, file_priv); 95 + if (ret) 96 + return ret; 97 + 98 + or->fb_id = r.fb_id; 99 + 100 + return 0; 101 + } 102 + 103 + static int format_check(const struct drm_mode_fb_cmd2 *r) 104 + { 105 + uint32_t format = r->pixel_format & ~DRM_FORMAT_BIG_ENDIAN; 106 + char *format_name; 107 + 108 + switch (format) { 109 + case DRM_FORMAT_C8: 110 + case DRM_FORMAT_RGB332: 111 + case DRM_FORMAT_BGR233: 112 + case DRM_FORMAT_XRGB4444: 113 + case DRM_FORMAT_XBGR4444: 114 + case DRM_FORMAT_RGBX4444: 115 + case DRM_FORMAT_BGRX4444: 116 + case DRM_FORMAT_ARGB4444: 117 + case DRM_FORMAT_ABGR4444: 118 + case DRM_FORMAT_RGBA4444: 119 + case DRM_FORMAT_BGRA4444: 120 + case DRM_FORMAT_XRGB1555: 121 + case DRM_FORMAT_XBGR1555: 122 + case DRM_FORMAT_RGBX5551: 123 + case DRM_FORMAT_BGRX5551: 124 + case DRM_FORMAT_ARGB1555: 125 + case DRM_FORMAT_ABGR1555: 126 + case DRM_FORMAT_RGBA5551: 127 + case DRM_FORMAT_BGRA5551: 128 + case DRM_FORMAT_RGB565: 129 + case DRM_FORMAT_BGR565: 130 + case DRM_FORMAT_RGB888: 131 + case DRM_FORMAT_BGR888: 132 + case DRM_FORMAT_XRGB8888: 133 + case DRM_FORMAT_XBGR8888: 134 + case DRM_FORMAT_RGBX8888: 135 + case DRM_FORMAT_BGRX8888: 136 + case DRM_FORMAT_ARGB8888: 137 + case DRM_FORMAT_ABGR8888: 138 + case DRM_FORMAT_RGBA8888: 139 + case DRM_FORMAT_BGRA8888: 140 + case DRM_FORMAT_XRGB2101010: 141 + case DRM_FORMAT_XBGR2101010: 142 + case DRM_FORMAT_RGBX1010102: 143 + case DRM_FORMAT_BGRX1010102: 144 + case DRM_FORMAT_ARGB2101010: 145 + case DRM_FORMAT_ABGR2101010: 146 + case DRM_FORMAT_RGBA1010102: 147 + case DRM_FORMAT_BGRA1010102: 148 + case DRM_FORMAT_YUYV: 149 + case DRM_FORMAT_YVYU: 150 + case DRM_FORMAT_UYVY: 151 + case DRM_FORMAT_VYUY: 152 + case DRM_FORMAT_AYUV: 153 + case DRM_FORMAT_NV12: 154 + case DRM_FORMAT_NV21: 155 + case DRM_FORMAT_NV16: 156 + case DRM_FORMAT_NV61: 157 + case DRM_FORMAT_NV24: 158 + case DRM_FORMAT_NV42: 159 + case DRM_FORMAT_YUV410: 160 + case DRM_FORMAT_YVU410: 161 + case DRM_FORMAT_YUV411: 162 + case DRM_FORMAT_YVU411: 163 + case DRM_FORMAT_YUV420: 164 + case DRM_FORMAT_YVU420: 165 + case DRM_FORMAT_YUV422: 166 + case DRM_FORMAT_YVU422: 167 + case DRM_FORMAT_YUV444: 168 + case DRM_FORMAT_YVU444: 169 + return 0; 170 + default: 171 + format_name = drm_get_format_name(r->pixel_format); 172 + DRM_DEBUG_KMS("invalid pixel format %s\n", format_name); 173 + kfree(format_name); 174 + return -EINVAL; 175 + } 176 + } 177 + 178 + static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) 179 + { 180 + int ret, hsub, vsub, num_planes, i; 181 + 182 + ret = format_check(r); 183 + if (ret) { 184 + char *format_name = drm_get_format_name(r->pixel_format); 185 + DRM_DEBUG_KMS("bad framebuffer format %s\n", format_name); 186 + kfree(format_name); 187 + return ret; 188 + } 189 + 190 + hsub = drm_format_horz_chroma_subsampling(r->pixel_format); 191 + vsub = drm_format_vert_chroma_subsampling(r->pixel_format); 192 + num_planes = drm_format_num_planes(r->pixel_format); 193 + 194 + if (r->width == 0 || r->width % hsub) { 195 + DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width); 196 + return -EINVAL; 197 + } 198 + 199 + if (r->height == 0 || r->height % vsub) { 200 + DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height); 201 + return -EINVAL; 202 + } 203 + 204 + for (i = 0; i < num_planes; i++) { 205 + unsigned int width = r->width / (i != 0 ? hsub : 1); 206 + unsigned int height = r->height / (i != 0 ? vsub : 1); 207 + unsigned int cpp = drm_format_plane_cpp(r->pixel_format, i); 208 + 209 + if (!r->handles[i]) { 210 + DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i); 211 + return -EINVAL; 212 + } 213 + 214 + if ((uint64_t) width * cpp > UINT_MAX) 215 + return -ERANGE; 216 + 217 + if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX) 218 + return -ERANGE; 219 + 220 + if (r->pitches[i] < width * cpp) { 221 + DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i); 222 + return -EINVAL; 223 + } 224 + 225 + if (r->modifier[i] && !(r->flags & DRM_MODE_FB_MODIFIERS)) { 226 + DRM_DEBUG_KMS("bad fb modifier %llu for plane %d\n", 227 + r->modifier[i], i); 228 + return -EINVAL; 229 + } 230 + 231 + /* modifier specific checks: */ 232 + switch (r->modifier[i]) { 233 + case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: 234 + /* NOTE: the pitch restriction may be lifted later if it turns 235 + * out that no hw has this restriction: 236 + */ 237 + if (r->pixel_format != DRM_FORMAT_NV12 || 238 + width % 128 || height % 32 || 239 + r->pitches[i] % 128) { 240 + DRM_DEBUG_KMS("bad modifier data for plane %d\n", i); 241 + return -EINVAL; 242 + } 243 + break; 244 + 245 + default: 246 + break; 247 + } 248 + } 249 + 250 + for (i = num_planes; i < 4; i++) { 251 + if (r->modifier[i]) { 252 + DRM_DEBUG_KMS("non-zero modifier for unused plane %d\n", i); 253 + return -EINVAL; 254 + } 255 + 256 + /* Pre-FB_MODIFIERS userspace didn't clear the structs properly. */ 257 + if (!(r->flags & DRM_MODE_FB_MODIFIERS)) 258 + continue; 259 + 260 + if (r->handles[i]) { 261 + DRM_DEBUG_KMS("buffer object handle for unused plane %d\n", i); 262 + return -EINVAL; 263 + } 264 + 265 + if (r->pitches[i]) { 266 + DRM_DEBUG_KMS("non-zero pitch for unused plane %d\n", i); 267 + return -EINVAL; 268 + } 269 + 270 + if (r->offsets[i]) { 271 + DRM_DEBUG_KMS("non-zero offset for unused plane %d\n", i); 272 + return -EINVAL; 273 + } 274 + } 275 + 276 + return 0; 277 + } 278 + 279 + struct drm_framebuffer * 280 + drm_internal_framebuffer_create(struct drm_device *dev, 281 + const struct drm_mode_fb_cmd2 *r, 282 + struct drm_file *file_priv) 283 + { 284 + struct drm_mode_config *config = &dev->mode_config; 285 + struct drm_framebuffer *fb; 286 + int ret; 287 + 288 + if (r->flags & ~(DRM_MODE_FB_INTERLACED | DRM_MODE_FB_MODIFIERS)) { 289 + DRM_DEBUG_KMS("bad framebuffer flags 0x%08x\n", r->flags); 290 + return ERR_PTR(-EINVAL); 291 + } 292 + 293 + if ((config->min_width > r->width) || (r->width > config->max_width)) { 294 + DRM_DEBUG_KMS("bad framebuffer width %d, should be >= %d && <= %d\n", 295 + r->width, config->min_width, config->max_width); 296 + return ERR_PTR(-EINVAL); 297 + } 298 + if ((config->min_height > r->height) || (r->height > config->max_height)) { 299 + DRM_DEBUG_KMS("bad framebuffer height %d, should be >= %d && <= %d\n", 300 + r->height, config->min_height, config->max_height); 301 + return ERR_PTR(-EINVAL); 302 + } 303 + 304 + if (r->flags & DRM_MODE_FB_MODIFIERS && 305 + !dev->mode_config.allow_fb_modifiers) { 306 + DRM_DEBUG_KMS("driver does not support fb modifiers\n"); 307 + return ERR_PTR(-EINVAL); 308 + } 309 + 310 + ret = framebuffer_check(r); 311 + if (ret) 312 + return ERR_PTR(ret); 313 + 314 + fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); 315 + if (IS_ERR(fb)) { 316 + DRM_DEBUG_KMS("could not create framebuffer\n"); 317 + return fb; 318 + } 319 + 320 + return fb; 321 + } 322 + 323 + /** 324 + * drm_mode_addfb2 - add an FB to the graphics configuration 325 + * @dev: drm device for the ioctl 326 + * @data: data pointer for the ioctl 327 + * @file_priv: drm file for the ioctl call 328 + * 329 + * Add a new FB to the specified CRTC, given a user request with format. This is 330 + * the 2nd version of the addfb ioctl, which supports multi-planar framebuffers 331 + * and uses fourcc codes as pixel format specifiers. 332 + * 333 + * Called by the user via ioctl. 334 + * 335 + * Returns: 336 + * Zero on success, negative errno on failure. 337 + */ 338 + int drm_mode_addfb2(struct drm_device *dev, 339 + void *data, struct drm_file *file_priv) 340 + { 341 + struct drm_mode_fb_cmd2 *r = data; 342 + struct drm_framebuffer *fb; 343 + 344 + if (!drm_core_check_feature(dev, DRIVER_MODESET)) 345 + return -EINVAL; 346 + 347 + fb = drm_internal_framebuffer_create(dev, r, file_priv); 348 + if (IS_ERR(fb)) 349 + return PTR_ERR(fb); 350 + 351 + DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id); 352 + r->fb_id = fb->base.id; 353 + 354 + /* Transfer ownership to the filp for reaping on close */ 355 + mutex_lock(&file_priv->fbs_lock); 356 + list_add(&fb->filp_head, &file_priv->fbs); 357 + mutex_unlock(&file_priv->fbs_lock); 358 + 359 + return 0; 360 + } 361 + 362 + struct drm_mode_rmfb_work { 363 + struct work_struct work; 364 + struct list_head fbs; 365 + }; 366 + 367 + static void drm_mode_rmfb_work_fn(struct work_struct *w) 368 + { 369 + struct drm_mode_rmfb_work *arg = container_of(w, typeof(*arg), work); 370 + 371 + while (!list_empty(&arg->fbs)) { 372 + struct drm_framebuffer *fb = 373 + list_first_entry(&arg->fbs, typeof(*fb), filp_head); 374 + 375 + list_del_init(&fb->filp_head); 376 + drm_framebuffer_remove(fb); 377 + } 378 + } 379 + 380 + /** 381 + * drm_mode_rmfb - remove an FB from the configuration 382 + * @dev: drm device for the ioctl 383 + * @data: data pointer for the ioctl 384 + * @file_priv: drm file for the ioctl call 385 + * 386 + * Remove the FB specified by the user. 387 + * 388 + * Called by the user via ioctl. 389 + * 390 + * Returns: 391 + * Zero on success, negative errno on failure. 392 + */ 393 + int drm_mode_rmfb(struct drm_device *dev, 394 + void *data, struct drm_file *file_priv) 395 + { 396 + struct drm_framebuffer *fb = NULL; 397 + struct drm_framebuffer *fbl = NULL; 398 + uint32_t *id = data; 399 + int found = 0; 400 + 401 + if (!drm_core_check_feature(dev, DRIVER_MODESET)) 402 + return -EINVAL; 403 + 404 + fb = drm_framebuffer_lookup(dev, *id); 405 + if (!fb) 406 + return -ENOENT; 407 + 408 + mutex_lock(&file_priv->fbs_lock); 409 + list_for_each_entry(fbl, &file_priv->fbs, filp_head) 410 + if (fb == fbl) 411 + found = 1; 412 + if (!found) { 413 + mutex_unlock(&file_priv->fbs_lock); 414 + goto fail_unref; 415 + } 416 + 417 + list_del_init(&fb->filp_head); 418 + mutex_unlock(&file_priv->fbs_lock); 419 + 420 + /* drop the reference we picked up in framebuffer lookup */ 421 + drm_framebuffer_unreference(fb); 422 + 423 + /* 424 + * we now own the reference that was stored in the fbs list 425 + * 426 + * drm_framebuffer_remove may fail with -EINTR on pending signals, 427 + * so run this in a separate stack as there's no way to correctly 428 + * handle this after the fb is already removed from the lookup table. 429 + */ 430 + if (drm_framebuffer_read_refcount(fb) > 1) { 431 + struct drm_mode_rmfb_work arg; 432 + 433 + INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn); 434 + INIT_LIST_HEAD(&arg.fbs); 435 + list_add_tail(&fb->filp_head, &arg.fbs); 436 + 437 + schedule_work(&arg.work); 438 + flush_work(&arg.work); 439 + destroy_work_on_stack(&arg.work); 440 + } else 441 + drm_framebuffer_unreference(fb); 442 + 443 + return 0; 444 + 445 + fail_unref: 446 + drm_framebuffer_unreference(fb); 447 + return -ENOENT; 448 + } 449 + 450 + /** 451 + * drm_mode_getfb - get FB info 452 + * @dev: drm device for the ioctl 453 + * @data: data pointer for the ioctl 454 + * @file_priv: drm file for the ioctl call 455 + * 456 + * Lookup the FB given its ID and return info about it. 457 + * 458 + * Called by the user via ioctl. 459 + * 460 + * Returns: 461 + * Zero on success, negative errno on failure. 462 + */ 463 + int drm_mode_getfb(struct drm_device *dev, 464 + void *data, struct drm_file *file_priv) 465 + { 466 + struct drm_mode_fb_cmd *r = data; 467 + struct drm_framebuffer *fb; 468 + int ret; 469 + 470 + if (!drm_core_check_feature(dev, DRIVER_MODESET)) 471 + return -EINVAL; 472 + 473 + fb = drm_framebuffer_lookup(dev, r->fb_id); 474 + if (!fb) 475 + return -ENOENT; 476 + 477 + r->height = fb->height; 478 + r->width = fb->width; 479 + r->depth = fb->depth; 480 + r->bpp = fb->bits_per_pixel; 481 + r->pitch = fb->pitches[0]; 482 + if (fb->funcs->create_handle) { 483 + if (drm_is_current_master(file_priv) || capable(CAP_SYS_ADMIN) || 484 + drm_is_control_client(file_priv)) { 485 + ret = fb->funcs->create_handle(fb, file_priv, 486 + &r->handle); 487 + } else { 488 + /* GET_FB() is an unprivileged ioctl so we must not 489 + * return a buffer-handle to non-master processes! For 490 + * backwards-compatibility reasons, we cannot make 491 + * GET_FB() privileged, so just return an invalid handle 492 + * for non-masters. */ 493 + r->handle = 0; 494 + ret = 0; 495 + } 496 + } else { 497 + ret = -ENODEV; 498 + } 499 + 500 + drm_framebuffer_unreference(fb); 501 + 502 + return ret; 503 + } 504 + 505 + /** 506 + * drm_mode_dirtyfb_ioctl - flush frontbuffer rendering on an FB 507 + * @dev: drm device for the ioctl 508 + * @data: data pointer for the ioctl 509 + * @file_priv: drm file for the ioctl call 510 + * 511 + * Lookup the FB and flush out the damaged area supplied by userspace as a clip 512 + * rectangle list. Generic userspace which does frontbuffer rendering must call 513 + * this ioctl to flush out the changes on manual-update display outputs, e.g. 514 + * usb display-link, mipi manual update panels or edp panel self refresh modes. 515 + * 516 + * Modesetting drivers which always update the frontbuffer do not need to 517 + * implement the corresponding ->dirty framebuffer callback. 518 + * 519 + * Called by the user via ioctl. 520 + * 521 + * Returns: 522 + * Zero on success, negative errno on failure. 523 + */ 524 + int drm_mode_dirtyfb_ioctl(struct drm_device *dev, 525 + void *data, struct drm_file *file_priv) 526 + { 527 + struct drm_clip_rect __user *clips_ptr; 528 + struct drm_clip_rect *clips = NULL; 529 + struct drm_mode_fb_dirty_cmd *r = data; 530 + struct drm_framebuffer *fb; 531 + unsigned flags; 532 + int num_clips; 533 + int ret; 534 + 535 + if (!drm_core_check_feature(dev, DRIVER_MODESET)) 536 + return -EINVAL; 537 + 538 + fb = drm_framebuffer_lookup(dev, r->fb_id); 539 + if (!fb) 540 + return -ENOENT; 541 + 542 + num_clips = r->num_clips; 543 + clips_ptr = (struct drm_clip_rect __user *)(unsigned long)r->clips_ptr; 544 + 545 + if (!num_clips != !clips_ptr) { 546 + ret = -EINVAL; 547 + goto out_err1; 548 + } 549 + 550 + flags = DRM_MODE_FB_DIRTY_FLAGS & r->flags; 551 + 552 + /* If userspace annotates copy, clips must come in pairs */ 553 + if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY && (num_clips % 2)) { 554 + ret = -EINVAL; 555 + goto out_err1; 556 + } 557 + 558 + if (num_clips && clips_ptr) { 559 + if (num_clips < 0 || num_clips > DRM_MODE_FB_DIRTY_MAX_CLIPS) { 560 + ret = -EINVAL; 561 + goto out_err1; 562 + } 563 + clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL); 564 + if (!clips) { 565 + ret = -ENOMEM; 566 + goto out_err1; 567 + } 568 + 569 + ret = copy_from_user(clips, clips_ptr, 570 + num_clips * sizeof(*clips)); 571 + if (ret) { 572 + ret = -EFAULT; 573 + goto out_err2; 574 + } 575 + } 576 + 577 + if (fb->funcs->dirty) { 578 + ret = fb->funcs->dirty(fb, file_priv, flags, r->color, 579 + clips, num_clips); 580 + } else { 581 + ret = -ENOSYS; 582 + } 583 + 584 + out_err2: 585 + kfree(clips); 586 + out_err1: 587 + drm_framebuffer_unreference(fb); 588 + 589 + return ret; 590 + } 591 + 592 + /** 593 + * drm_fb_release - remove and free the FBs on this file 594 + * @priv: drm file for the ioctl 595 + * 596 + * Destroy all the FBs associated with @filp. 597 + * 598 + * Called by the user via ioctl. 599 + * 600 + * Returns: 601 + * Zero on success, negative errno on failure. 602 + */ 603 + void drm_fb_release(struct drm_file *priv) 604 + { 605 + struct drm_framebuffer *fb, *tfb; 606 + struct drm_mode_rmfb_work arg; 607 + 608 + INIT_LIST_HEAD(&arg.fbs); 609 + 610 + /* 611 + * When the file gets released that means no one else can access the fb 612 + * list any more, so no need to grab fpriv->fbs_lock. And we need to 613 + * avoid upsetting lockdep since the universal cursor code adds a 614 + * framebuffer while holding mutex locks. 615 + * 616 + * Note that a real deadlock between fpriv->fbs_lock and the modeset 617 + * locks is impossible here since no one else but this function can get 618 + * at it any more. 619 + */ 620 + list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { 621 + if (drm_framebuffer_read_refcount(fb) > 1) { 622 + list_move_tail(&fb->filp_head, &arg.fbs); 623 + } else { 624 + list_del_init(&fb->filp_head); 625 + 626 + /* This drops the fpriv->fbs reference. */ 627 + drm_framebuffer_unreference(fb); 628 + } 629 + } 630 + 631 + if (!list_empty(&arg.fbs)) { 632 + INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn); 633 + 634 + schedule_work(&arg.work); 635 + flush_work(&arg.work); 636 + destroy_work_on_stack(&arg.work); 637 + } 638 + } 639 + 640 + void drm_framebuffer_free(struct kref *kref) 641 + { 642 + struct drm_framebuffer *fb = 643 + container_of(kref, struct drm_framebuffer, base.refcount); 644 + struct drm_device *dev = fb->dev; 645 + 646 + /* 647 + * The lookup idr holds a weak reference, which has not necessarily been 648 + * removed at this point. Check for that. 649 + */ 650 + drm_mode_object_unregister(dev, &fb->base); 651 + 652 + fb->funcs->destroy(fb); 653 + } 654 + 655 + /** 656 + * drm_framebuffer_init - initialize a framebuffer 657 + * @dev: DRM device 658 + * @fb: framebuffer to be initialized 659 + * @funcs: ... with these functions 660 + * 661 + * Allocates an ID for the framebuffer's parent mode object, sets its mode 662 + * functions & device file and adds it to the master fd list. 663 + * 664 + * IMPORTANT: 665 + * This functions publishes the fb and makes it available for concurrent access 666 + * by other users. Which means by this point the fb _must_ be fully set up - 667 + * since all the fb attributes are invariant over its lifetime, no further 668 + * locking but only correct reference counting is required. 669 + * 670 + * Returns: 671 + * Zero on success, error code on failure. 672 + */ 673 + int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, 674 + const struct drm_framebuffer_funcs *funcs) 675 + { 676 + int ret; 677 + 678 + INIT_LIST_HEAD(&fb->filp_head); 679 + fb->dev = dev; 680 + fb->funcs = funcs; 681 + 682 + ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB, 683 + false, drm_framebuffer_free); 684 + if (ret) 685 + goto out; 686 + 687 + mutex_lock(&dev->mode_config.fb_lock); 688 + dev->mode_config.num_fb++; 689 + list_add(&fb->head, &dev->mode_config.fb_list); 690 + mutex_unlock(&dev->mode_config.fb_lock); 691 + 692 + drm_mode_object_register(dev, &fb->base); 693 + out: 694 + return ret; 695 + } 696 + EXPORT_SYMBOL(drm_framebuffer_init); 697 + 698 + /** 699 + * drm_framebuffer_lookup - look up a drm framebuffer and grab a reference 700 + * @dev: drm device 701 + * @id: id of the fb object 702 + * 703 + * If successful, this grabs an additional reference to the framebuffer - 704 + * callers need to make sure to eventually unreference the returned framebuffer 705 + * again, using @drm_framebuffer_unreference. 706 + */ 707 + struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, 708 + uint32_t id) 709 + { 710 + struct drm_mode_object *obj; 711 + struct drm_framebuffer *fb = NULL; 712 + 713 + obj = __drm_mode_object_find(dev, id, DRM_MODE_OBJECT_FB); 714 + if (obj) 715 + fb = obj_to_fb(obj); 716 + return fb; 717 + } 718 + EXPORT_SYMBOL(drm_framebuffer_lookup); 719 + 720 + /** 721 + * drm_framebuffer_unregister_private - unregister a private fb from the lookup idr 722 + * @fb: fb to unregister 723 + * 724 + * Drivers need to call this when cleaning up driver-private framebuffers, e.g. 725 + * those used for fbdev. Note that the caller must hold a reference of it's own, 726 + * i.e. the object may not be destroyed through this call (since it'll lead to a 727 + * locking inversion). 728 + */ 729 + void drm_framebuffer_unregister_private(struct drm_framebuffer *fb) 730 + { 731 + struct drm_device *dev; 732 + 733 + if (!fb) 734 + return; 735 + 736 + dev = fb->dev; 737 + 738 + /* Mark fb as reaped and drop idr ref. */ 739 + drm_mode_object_unregister(dev, &fb->base); 740 + } 741 + EXPORT_SYMBOL(drm_framebuffer_unregister_private); 742 + 743 + /** 744 + * drm_framebuffer_cleanup - remove a framebuffer object 745 + * @fb: framebuffer to remove 746 + * 747 + * Cleanup framebuffer. This function is intended to be used from the drivers 748 + * ->destroy callback. It can also be used to clean up driver private 749 + * framebuffers embedded into a larger structure. 750 + * 751 + * Note that this function does not remove the fb from active usuage - if it is 752 + * still used anywhere, hilarity can ensue since userspace could call getfb on 753 + * the id and get back -EINVAL. Obviously no concern at driver unload time. 754 + * 755 + * Also, the framebuffer will not be removed from the lookup idr - for 756 + * user-created framebuffers this will happen in in the rmfb ioctl. For 757 + * driver-private objects (e.g. for fbdev) drivers need to explicitly call 758 + * drm_framebuffer_unregister_private. 759 + */ 760 + void drm_framebuffer_cleanup(struct drm_framebuffer *fb) 761 + { 762 + struct drm_device *dev = fb->dev; 763 + 764 + mutex_lock(&dev->mode_config.fb_lock); 765 + list_del(&fb->head); 766 + dev->mode_config.num_fb--; 767 + mutex_unlock(&dev->mode_config.fb_lock); 768 + } 769 + EXPORT_SYMBOL(drm_framebuffer_cleanup); 770 + 771 + /** 772 + * drm_framebuffer_remove - remove and unreference a framebuffer object 773 + * @fb: framebuffer to remove 774 + * 775 + * Scans all the CRTCs and planes in @dev's mode_config. If they're 776 + * using @fb, removes it, setting it to NULL. Then drops the reference to the 777 + * passed-in framebuffer. Might take the modeset locks. 778 + * 779 + * Note that this function optimizes the cleanup away if the caller holds the 780 + * last reference to the framebuffer. It is also guaranteed to not take the 781 + * modeset locks in this case. 782 + */ 783 + void drm_framebuffer_remove(struct drm_framebuffer *fb) 784 + { 785 + struct drm_device *dev; 786 + struct drm_crtc *crtc; 787 + struct drm_plane *plane; 788 + 789 + if (!fb) 790 + return; 791 + 792 + dev = fb->dev; 793 + 794 + WARN_ON(!list_empty(&fb->filp_head)); 795 + 796 + /* 797 + * drm ABI mandates that we remove any deleted framebuffers from active 798 + * useage. But since most sane clients only remove framebuffers they no 799 + * longer need, try to optimize this away. 800 + * 801 + * Since we're holding a reference ourselves, observing a refcount of 1 802 + * means that we're the last holder and can skip it. Also, the refcount 803 + * can never increase from 1 again, so we don't need any barriers or 804 + * locks. 805 + * 806 + * Note that userspace could try to race with use and instate a new 807 + * usage _after_ we've cleared all current ones. End result will be an 808 + * in-use fb with fb-id == 0. Userspace is allowed to shoot its own foot 809 + * in this manner. 810 + */ 811 + if (drm_framebuffer_read_refcount(fb) > 1) { 812 + drm_modeset_lock_all(dev); 813 + /* remove from any CRTC */ 814 + drm_for_each_crtc(crtc, dev) { 815 + if (crtc->primary->fb == fb) { 816 + /* should turn off the crtc */ 817 + if (drm_crtc_force_disable(crtc)) 818 + DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc); 819 + } 820 + } 821 + 822 + drm_for_each_plane(plane, dev) { 823 + if (plane->fb == fb) 824 + drm_plane_force_disable(plane); 825 + } 826 + drm_modeset_unlock_all(dev); 827 + } 828 + 829 + drm_framebuffer_unreference(fb); 830 + } 831 + EXPORT_SYMBOL(drm_framebuffer_remove);
+1
drivers/gpu/drm/drm_ioc32.c
··· 346 346 struct drm_stats __user *stats; 347 347 int i, err; 348 348 349 + memset(&s32, 0, sizeof(drm_stats32_t)); 349 350 stats = compat_alloc_user_space(sizeof(*stats)); 350 351 if (!stats) 351 352 return -EFAULT;
+4 -4
drivers/gpu/drm/drm_irq.c
··· 713 713 * Negative value on error, failure or if not supported in current 714 714 * video mode: 715 715 * 716 - * -EINVAL - Invalid CRTC. 717 - * -EAGAIN - Temporary unavailable, e.g., called before initial modeset. 718 - * -ENOTSUPP - Function not supported in current display mode. 719 - * -EIO - Failed, e.g., due to failed scanout position query. 716 + * -EINVAL Invalid CRTC. 717 + * -EAGAIN Temporary unavailable, e.g., called before initial modeset. 718 + * -ENOTSUPP Function not supported in current display mode. 719 + * -EIO Failed, e.g., due to failed scanout position query. 720 720 * 721 721 * Returns or'ed positive status flags on success: 722 722 *
+2 -1
drivers/gpu/drm/drm_kms_helper_common.c
··· 27 27 28 28 #include <drm/drmP.h> 29 29 #include <drm/drm_fb_helper.h> 30 - #include <drm/drm_dp_aux_dev.h> 30 + 31 + #include "drm_crtc_helper_internal.h" 31 32 32 33 MODULE_AUTHOR("David Airlie, Jesse Barnes"); 33 34 MODULE_DESCRIPTION("DRM KMS helper");
+10
drivers/gpu/drm/drm_modes.c
··· 657 657 } 658 658 EXPORT_SYMBOL_GPL(drm_display_mode_to_videomode); 659 659 660 + /** 661 + * drm_bus_flags_from_videomode - extract information about pixelclk and 662 + * DE polarity from videomode and store it in a separate variable 663 + * @vm: videomode structure to use 664 + * @bus_flags: information about pixelclk and DE polarity will be stored here 665 + * 666 + * Sets DRM_BUS_FLAG_DE_(LOW|HIGH) and DRM_BUS_FLAG_PIXDATA_(POS|NEG)EDGE 667 + * in @bus_flags according to DISPLAY_FLAGS found in @vm 668 + */ 660 669 void drm_bus_flags_from_videomode(const struct videomode *vm, u32 *bus_flags) 661 670 { 662 671 *bus_flags = 0; ··· 686 677 * of_get_drm_display_mode - get a drm_display_mode from devicetree 687 678 * @np: device_node with the timing specification 688 679 * @dmode: will be set to the return value 680 + * @bus_flags: information about pixelclk and DE polarity 689 681 * @index: index into the list of display timings in devicetree 690 682 * 691 683 * This function is expensive and should only be used, if only one mode is to be
+153
drivers/gpu/drm/drm_modeset_helper.c
··· 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_modeset_helper.h> 24 + #include <drm/drm_plane_helper.h> 25 + 26 + /** 27 + * DOC: aux kms helpers 28 + * 29 + * This helper library contains various one-off functions which don't really fit 30 + * anywhere else in the DRM modeset helper library. 31 + */ 32 + 33 + /** 34 + * drm_helper_move_panel_connectors_to_head() - move panels to the front in the 35 + * connector list 36 + * @dev: drm device to operate on 37 + * 38 + * Some userspace presumes that the first connected connector is the main 39 + * display, where it's supposed to display e.g. the login screen. For 40 + * laptops, this should be the main panel. Use this function to sort all 41 + * (eDP/LVDS) panels to the front of the connector list, instead of 42 + * painstakingly trying to initialize them in the right order. 43 + */ 44 + void drm_helper_move_panel_connectors_to_head(struct drm_device *dev) 45 + { 46 + struct drm_connector *connector, *tmp; 47 + struct list_head panel_list; 48 + 49 + INIT_LIST_HEAD(&panel_list); 50 + 51 + list_for_each_entry_safe(connector, tmp, 52 + &dev->mode_config.connector_list, head) { 53 + if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS || 54 + connector->connector_type == DRM_MODE_CONNECTOR_eDP) 55 + list_move_tail(&connector->head, &panel_list); 56 + } 57 + 58 + list_splice(&panel_list, &dev->mode_config.connector_list); 59 + } 60 + EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head); 61 + 62 + /** 63 + * drm_helper_mode_fill_fb_struct - fill out framebuffer metadata 64 + * @fb: drm_framebuffer object to fill out 65 + * @mode_cmd: metadata from the userspace fb creation request 66 + * 67 + * This helper can be used in a drivers fb_create callback to pre-fill the fb's 68 + * metadata fields. 69 + */ 70 + void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, 71 + const struct drm_mode_fb_cmd2 *mode_cmd) 72 + { 73 + int i; 74 + 75 + fb->width = mode_cmd->width; 76 + fb->height = mode_cmd->height; 77 + for (i = 0; i < 4; i++) { 78 + fb->pitches[i] = mode_cmd->pitches[i]; 79 + fb->offsets[i] = mode_cmd->offsets[i]; 80 + fb->modifier[i] = mode_cmd->modifier[i]; 81 + } 82 + drm_fb_get_bpp_depth(mode_cmd->pixel_format, &fb->depth, 83 + &fb->bits_per_pixel); 84 + fb->pixel_format = mode_cmd->pixel_format; 85 + fb->flags = mode_cmd->flags; 86 + } 87 + EXPORT_SYMBOL(drm_helper_mode_fill_fb_struct); 88 + 89 + /* 90 + * This is the minimal list of formats that seem to be safe for modeset use 91 + * with all current DRM drivers. Most hardware can actually support more 92 + * formats than this and drivers may specify a more accurate list when 93 + * creating the primary plane. However drivers that still call 94 + * drm_plane_init() will use this minimal format list as the default. 95 + */ 96 + static const uint32_t safe_modeset_formats[] = { 97 + DRM_FORMAT_XRGB8888, 98 + DRM_FORMAT_ARGB8888, 99 + }; 100 + 101 + static struct drm_plane *create_primary_plane(struct drm_device *dev) 102 + { 103 + struct drm_plane *primary; 104 + int ret; 105 + 106 + primary = kzalloc(sizeof(*primary), GFP_KERNEL); 107 + if (primary == NULL) { 108 + DRM_DEBUG_KMS("Failed to allocate primary plane\n"); 109 + return NULL; 110 + } 111 + 112 + /* 113 + * Remove the format_default field from drm_plane when dropping 114 + * this helper. 115 + */ 116 + primary->format_default = true; 117 + 118 + /* possible_crtc's will be filled in later by crtc_init */ 119 + ret = drm_universal_plane_init(dev, primary, 0, 120 + &drm_primary_helper_funcs, 121 + safe_modeset_formats, 122 + ARRAY_SIZE(safe_modeset_formats), 123 + DRM_PLANE_TYPE_PRIMARY, NULL); 124 + if (ret) { 125 + kfree(primary); 126 + primary = NULL; 127 + } 128 + 129 + return primary; 130 + } 131 + 132 + /** 133 + * drm_crtc_init - Legacy CRTC initialization function 134 + * @dev: DRM device 135 + * @crtc: CRTC object to init 136 + * @funcs: callbacks for the new CRTC 137 + * 138 + * Initialize a CRTC object with a default helper-provided primary plane and no 139 + * cursor plane. 140 + * 141 + * Returns: 142 + * Zero on success, error code on failure. 143 + */ 144 + int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, 145 + const struct drm_crtc_funcs *funcs) 146 + { 147 + struct drm_plane *primary; 148 + 149 + primary = create_primary_plane(dev); 150 + return drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs, 151 + NULL); 152 + } 153 + EXPORT_SYMBOL(drm_crtc_init);
+1 -67
drivers/gpu/drm/drm_plane_helper.c
··· 64 64 */ 65 65 66 66 /* 67 - * This is the minimal list of formats that seem to be safe for modeset use 68 - * with all current DRM drivers. Most hardware can actually support more 69 - * formats than this and drivers may specify a more accurate list when 70 - * creating the primary plane. However drivers that still call 71 - * drm_plane_init() will use this minimal format list as the default. 72 - */ 73 - static const uint32_t safe_modeset_formats[] = { 74 - DRM_FORMAT_XRGB8888, 75 - DRM_FORMAT_ARGB8888, 76 - }; 77 - 78 - /* 79 67 * Returns the connectors currently associated with a CRTC. This function 80 68 * should be called twice: once with a NULL connector list to retrieve 81 69 * the list size, and once with the properly allocated list to be filled in. ··· 199 211 * @crtc: owning CRTC of owning plane 200 212 * @fb: framebuffer to flip onto plane 201 213 * @src: source coordinates in 16.16 fixed point 202 - * @dest: integer destination coordinates 214 + * @dst: integer destination coordinates 203 215 * @clip: integer clipping coordinates 204 216 * @rotation: plane rotation 205 217 * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point ··· 425 437 .destroy = drm_primary_helper_destroy, 426 438 }; 427 439 EXPORT_SYMBOL(drm_primary_helper_funcs); 428 - 429 - static struct drm_plane *create_primary_plane(struct drm_device *dev) 430 - { 431 - struct drm_plane *primary; 432 - int ret; 433 - 434 - primary = kzalloc(sizeof(*primary), GFP_KERNEL); 435 - if (primary == NULL) { 436 - DRM_DEBUG_KMS("Failed to allocate primary plane\n"); 437 - return NULL; 438 - } 439 - 440 - /* 441 - * Remove the format_default field from drm_plane when dropping 442 - * this helper. 443 - */ 444 - primary->format_default = true; 445 - 446 - /* possible_crtc's will be filled in later by crtc_init */ 447 - ret = drm_universal_plane_init(dev, primary, 0, 448 - &drm_primary_helper_funcs, 449 - safe_modeset_formats, 450 - ARRAY_SIZE(safe_modeset_formats), 451 - DRM_PLANE_TYPE_PRIMARY, NULL); 452 - if (ret) { 453 - kfree(primary); 454 - primary = NULL; 455 - } 456 - 457 - return primary; 458 - } 459 - 460 - /** 461 - * drm_crtc_init - Legacy CRTC initialization function 462 - * @dev: DRM device 463 - * @crtc: CRTC object to init 464 - * @funcs: callbacks for the new CRTC 465 - * 466 - * Initialize a CRTC object with a default helper-provided primary plane and no 467 - * cursor plane. 468 - * 469 - * Returns: 470 - * Zero on success, error code on failure. 471 - */ 472 - int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, 473 - const struct drm_crtc_funcs *funcs) 474 - { 475 - struct drm_plane *primary; 476 - 477 - primary = create_primary_plane(dev); 478 - return drm_crtc_init_with_planes(dev, crtc, primary, NULL, funcs, 479 - NULL); 480 - } 481 - EXPORT_SYMBOL(drm_crtc_init); 482 440 483 441 int drm_plane_helper_commit(struct drm_plane *plane, 484 442 struct drm_plane_state *plane_state,
+1 -1
drivers/gpu/drm/drm_simple_kms_helper.c
··· 137 137 * @dev: DRM device 138 138 * @pipe: simple display pipe object to initialize 139 139 * @funcs: callbacks for the display pipe (optional) 140 - * @formats: array of supported formats (%DRM_FORMAT_*) 140 + * @formats: array of supported formats (DRM_FORMAT\_\*) 141 141 * @format_count: number of elements in @formats 142 142 * @connector: connector to attach and register 143 143 *
+1 -4
drivers/gpu/drm/etnaviv/etnaviv_drv.c
··· 488 488 }; 489 489 490 490 static struct drm_driver etnaviv_drm_driver = { 491 - .driver_features = DRIVER_HAVE_IRQ | 492 - DRIVER_GEM | 491 + .driver_features = DRIVER_GEM | 493 492 DRIVER_PRIME | 494 493 DRIVER_RENDER, 495 494 .open = etnaviv_open, ··· 531 532 drm = drm_dev_alloc(&etnaviv_drm_driver, dev); 532 533 if (!drm) 533 534 return -ENOMEM; 534 - 535 - drm->platformdev = to_platform_device(dev); 536 535 537 536 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 538 537 if (!priv) {
-15
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
··· 169 169 return; 170 170 } 171 171 172 - static void 173 - fsl_dcu_drm_plane_cleanup_fb(struct drm_plane *plane, 174 - const struct drm_plane_state *new_state) 175 - { 176 - } 177 - 178 - static int 179 - fsl_dcu_drm_plane_prepare_fb(struct drm_plane *plane, 180 - const struct drm_plane_state *new_state) 181 - { 182 - return 0; 183 - } 184 - 185 172 static const struct drm_plane_helper_funcs fsl_dcu_drm_plane_helper_funcs = { 186 173 .atomic_check = fsl_dcu_drm_plane_atomic_check, 187 174 .atomic_disable = fsl_dcu_drm_plane_atomic_disable, 188 175 .atomic_update = fsl_dcu_drm_plane_atomic_update, 189 - .cleanup_fb = fsl_dcu_drm_plane_cleanup_fb, 190 - .prepare_fb = fsl_dcu_drm_plane_prepare_fb, 191 176 }; 192 177 193 178 static void fsl_dcu_drm_plane_destroy(struct drm_plane *plane)
-8
drivers/gpu/drm/gma500/cdv_intel_lvds.c
··· 415 415 if (ret) 416 416 return ret; 417 417 418 - /* Didn't get an EDID, so 419 - * Set wide sync ranges so we get all modes 420 - * handed to valid_mode for checking 421 - */ 422 - connector->display_info.min_vfreq = 0; 423 - connector->display_info.max_vfreq = 200; 424 - connector->display_info.min_hfreq = 0; 425 - connector->display_info.max_hfreq = 200; 426 418 if (mode_dev->panel_fixed_mode != NULL) { 427 419 struct drm_display_mode *mode = 428 420 drm_mode_duplicate(dev, mode_dev->panel_fixed_mode);
-5
drivers/gpu/drm/gma500/mdfld_dsi_output.c
··· 335 335 struct drm_display_mode *dup_mode = NULL; 336 336 struct drm_device *dev = connector->dev; 337 337 338 - connector->display_info.min_vfreq = 0; 339 - connector->display_info.max_vfreq = 200; 340 - connector->display_info.min_hfreq = 0; 341 - connector->display_info.max_hfreq = 200; 342 - 343 338 if (fixed_mode) { 344 339 dev_dbg(dev->dev, "fixed_mode %dx%d\n", 345 340 fixed_mode->hdisplay, fixed_mode->vdisplay);
-9
drivers/gpu/drm/gma500/psb_intel_lvds.c
··· 530 530 if (ret) 531 531 return ret; 532 532 533 - /* Didn't get an EDID, so 534 - * Set wide sync ranges so we get all modes 535 - * handed to valid_mode for checking 536 - */ 537 - connector->display_info.min_vfreq = 0; 538 - connector->display_info.max_vfreq = 200; 539 - connector->display_info.min_hfreq = 0; 540 - connector->display_info.max_hfreq = 200; 541 - 542 533 if (mode_dev->panel_fixed_mode != NULL) { 543 534 struct drm_display_mode *mode = 544 535 drm_mode_duplicate(dev, mode_dev->panel_fixed_mode);
+4 -17
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
··· 608 608 u32 ch, u32 y, u32 in_h, u32 fmt) 609 609 { 610 610 struct drm_gem_cma_object *obj = drm_fb_cma_get_gem_obj(fb, 0); 611 + char *format_name; 611 612 u32 reg_ctrl, reg_addr, reg_size, reg_stride, reg_space, reg_en; 612 613 u32 stride = fb->pitches[0]; 613 614 u32 addr = (u32)obj->paddr + y * stride; 614 615 615 616 DRM_DEBUG_DRIVER("rdma%d: (y=%d, height=%d), stride=%d, paddr=0x%x\n", 616 617 ch + 1, y, in_h, stride, (u32)obj->paddr); 618 + format_name = drm_get_format_name(fb->pixel_format); 617 619 DRM_DEBUG_DRIVER("addr=0x%x, fb:%dx%d, pixel_format=%d(%s)\n", 618 - addr, fb->width, fb->height, fmt, 619 - drm_get_format_name(fb->pixel_format)); 620 + addr, fb->width, fb->height, fmt, format_name); 621 + kfree(format_name); 620 622 621 623 /* get reg offset */ 622 624 reg_ctrl = RD_CH_CTRL(ch); ··· 817 815 ade_compositor_routing_disable(base, ch); 818 816 } 819 817 820 - static int ade_plane_prepare_fb(struct drm_plane *plane, 821 - const struct drm_plane_state *new_state) 822 - { 823 - /* do nothing */ 824 - return 0; 825 - } 826 - 827 - static void ade_plane_cleanup_fb(struct drm_plane *plane, 828 - const struct drm_plane_state *old_state) 829 - { 830 - /* do nothing */ 831 - } 832 - 833 818 static int ade_plane_atomic_check(struct drm_plane *plane, 834 819 struct drm_plane_state *state) 835 820 { ··· 884 895 } 885 896 886 897 static const struct drm_plane_helper_funcs ade_plane_helper_funcs = { 887 - .prepare_fb = ade_plane_prepare_fb, 888 - .cleanup_fb = ade_plane_cleanup_fb, 889 898 .atomic_check = ade_plane_atomic_check, 890 899 .atomic_update = ade_plane_atomic_update, 891 900 .atomic_disable = ade_plane_atomic_disable,
+1 -1
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
··· 169 169 170 170 static struct drm_driver kirin_drm_driver = { 171 171 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | 172 - DRIVER_ATOMIC | DRIVER_HAVE_IRQ, 172 + DRIVER_ATOMIC, 173 173 .fops = &kirin_drm_fops, 174 174 175 175 .gem_free_object_unlocked = drm_gem_cma_free_object,
+10 -1
drivers/gpu/drm/i915/i915_debugfs.c
··· 3113 3113 for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) { 3114 3114 struct drm_plane_state *state; 3115 3115 struct drm_plane *plane = &intel_plane->base; 3116 + char *format_name; 3116 3117 3117 3118 if (!plane->state) { 3118 3119 seq_puts(m, "plane->state is NULL!\n"); ··· 3121 3120 } 3122 3121 3123 3122 state = plane->state; 3123 + 3124 + if (state->fb) { 3125 + format_name = drm_get_format_name(state->fb->pixel_format); 3126 + } else { 3127 + format_name = kstrdup("N/A", GFP_KERNEL); 3128 + } 3124 3129 3125 3130 seq_printf(m, "\t--Plane id %d: type=%s, crtc_pos=%4dx%4d, crtc_size=%4dx%4d, src_pos=%d.%04ux%d.%04u, src_size=%d.%04ux%d.%04u, format=%s, rotation=%s\n", 3126 3131 plane->base.id, ··· 3141 3134 ((state->src_w & 0xffff) * 15625) >> 10, 3142 3135 (state->src_h >> 16), 3143 3136 ((state->src_h & 0xffff) * 15625) >> 10, 3144 - state->fb ? drm_get_format_name(state->fb->pixel_format) : "N/A", 3137 + format_name, 3145 3138 plane_rotation(state->rotation)); 3139 + 3140 + kfree(format_name); 3146 3141 } 3147 3142 } 3148 3143
+21 -21
drivers/gpu/drm/i915/i915_vgpu.c
··· 156 156 * host point of view, the graphic address space is partitioned by multiple 157 157 * vGPUs in different VMs. :: 158 158 * 159 - * vGPU1 view Host view 160 - * 0 ------> +-----------+ +-----------+ 161 - * ^ |###########| | vGPU3 | 162 - * | |###########| +-----------+ 163 - * | |###########| | vGPU2 | 164 - * | +-----------+ +-----------+ 165 - * mappable GM | available | ==> | vGPU1 | 166 - * | +-----------+ +-----------+ 167 - * | |###########| | | 168 - * v |###########| | Host | 169 - * +=======+===========+ +===========+ 170 - * ^ |###########| | vGPU3 | 171 - * | |###########| +-----------+ 172 - * | |###########| | vGPU2 | 173 - * | +-----------+ +-----------+ 174 - * unmappable GM | available | ==> | vGPU1 | 175 - * | +-----------+ +-----------+ 176 - * | |###########| | | 177 - * | |###########| | Host | 178 - * v |###########| | | 179 - * total GM size ------> +-----------+ +-----------+ 159 + * vGPU1 view Host view 160 + * 0 ------> +-----------+ +-----------+ 161 + * ^ |###########| | vGPU3 | 162 + * | |###########| +-----------+ 163 + * | |###########| | vGPU2 | 164 + * | +-----------+ +-----------+ 165 + * mappable GM | available | ==> | vGPU1 | 166 + * | +-----------+ +-----------+ 167 + * | |###########| | | 168 + * v |###########| | Host | 169 + * +=======+===========+ +===========+ 170 + * ^ |###########| | vGPU3 | 171 + * | |###########| +-----------+ 172 + * | |###########| | vGPU2 | 173 + * | +-----------+ +-----------+ 174 + * unmappable GM | available | ==> | vGPU1 | 175 + * | +-----------+ +-----------+ 176 + * | |###########| | | 177 + * | |###########| | Host | 178 + * v |###########| | | 179 + * total GM size ------> +-----------+ +-----------+ 180 180 * 181 181 * Returns: 182 182 * zero on success, non-zero if configuration invalid or ballooning failed
+4 -2
drivers/gpu/drm/i915/intel_atomic_plane.c
··· 143 143 crtc_state->base.enable ? crtc_state->pipe_src_h : 0; 144 144 145 145 if (state->fb && intel_rotation_90_or_270(state->rotation)) { 146 + char *format_name; 146 147 if (!(state->fb->modifier[0] == I915_FORMAT_MOD_Y_TILED || 147 148 state->fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED)) { 148 149 DRM_DEBUG_KMS("Y/Yf tiling required for 90/270!\n"); ··· 158 157 switch (state->fb->pixel_format) { 159 158 case DRM_FORMAT_C8: 160 159 case DRM_FORMAT_RGB565: 161 - DRM_DEBUG_KMS("Unsupported pixel format %s for 90/270!\n", 162 - drm_get_format_name(state->fb->pixel_format)); 160 + format_name = drm_get_format_name(state->fb->pixel_format); 161 + DRM_DEBUG_KMS("Unsupported pixel format %s for 90/270!\n", format_name); 162 + kfree(format_name); 163 163 return -EINVAL; 164 164 165 165 default:
+3 -3
drivers/gpu/drm/i915/intel_audio.c
··· 51 51 * related registers. (The notable exception is the power management, not 52 52 * covered here.) 53 53 * 54 - * The struct i915_audio_component is used to interact between the graphics 55 - * and audio drivers. The struct i915_audio_component_ops *ops in it is 54 + * The struct &i915_audio_component is used to interact between the graphics 55 + * and audio drivers. The struct &i915_audio_component_ops @ops in it is 56 56 * defined in graphics driver and called in audio driver. The 57 - * struct i915_audio_component_audio_ops *audio_ops is called from i915 driver. 57 + * struct &i915_audio_component_audio_ops @audio_ops is called from i915 driver. 58 58 */ 59 59 60 60 static const struct {
+27 -16
drivers/gpu/drm/i915/intel_display.c
··· 12258 12258 12259 12259 DRM_DEBUG_KMS("planes on this crtc\n"); 12260 12260 list_for_each_entry(plane, &dev->mode_config.plane_list, head) { 12261 + char *format_name; 12261 12262 intel_plane = to_intel_plane(plane); 12262 12263 if (intel_plane->pipe != crtc->pipe) 12263 12264 continue; ··· 12271 12270 continue; 12272 12271 } 12273 12272 12273 + format_name = drm_get_format_name(fb->pixel_format); 12274 + 12274 12275 DRM_DEBUG_KMS("[PLANE:%d:%s] enabled", 12275 12276 plane->base.id, plane->name); 12276 12277 DRM_DEBUG_KMS("\tFB:%d, fb = %ux%u format = %s", 12277 - fb->base.id, fb->width, fb->height, 12278 - drm_get_format_name(fb->pixel_format)); 12278 + fb->base.id, fb->width, fb->height, format_name); 12279 12279 DRM_DEBUG_KMS("\tscaler:%d src %dx%d+%d+%d dst %dx%d+%d+%d\n", 12280 12280 state->scaler_id, 12281 12281 state->base.src.x1 >> 16, ··· 12286 12284 state->base.dst.x1, state->base.dst.y1, 12287 12285 drm_rect_width(&state->base.dst), 12288 12286 drm_rect_height(&state->base.dst)); 12287 + 12288 + kfree(format_name); 12289 12289 } 12290 12290 } 12291 12291 ··· 13976 13972 */ 13977 13973 int 13978 13974 intel_prepare_plane_fb(struct drm_plane *plane, 13979 - const struct drm_plane_state *new_state) 13975 + struct drm_plane_state *new_state) 13980 13976 { 13981 13977 struct drm_device *dev = plane->dev; 13982 13978 struct drm_framebuffer *fb = new_state->fb; ··· 14058 14054 */ 14059 14055 void 14060 14056 intel_cleanup_plane_fb(struct drm_plane *plane, 14061 - const struct drm_plane_state *old_state) 14057 + struct drm_plane_state *old_state) 14062 14058 { 14063 14059 struct drm_device *dev = plane->dev; 14064 14060 struct intel_plane_state *old_intel_state; ··· 14915 14911 unsigned int aligned_height; 14916 14912 int ret; 14917 14913 u32 pitch_limit, stride_alignment; 14914 + char *format_name; 14918 14915 14919 14916 WARN_ON(!mutex_is_locked(&dev->struct_mutex)); 14920 14917 ··· 14990 14985 break; 14991 14986 case DRM_FORMAT_XRGB1555: 14992 14987 if (INTEL_INFO(dev)->gen > 3) { 14993 - DRM_DEBUG("unsupported pixel format: %s\n", 14994 - drm_get_format_name(mode_cmd->pixel_format)); 14988 + format_name = drm_get_format_name(mode_cmd->pixel_format); 14989 + DRM_DEBUG("unsupported pixel format: %s\n", format_name); 14990 + kfree(format_name); 14995 14991 return -EINVAL; 14996 14992 } 14997 14993 break; 14998 14994 case DRM_FORMAT_ABGR8888: 14999 14995 if (!IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev) && 15000 14996 INTEL_INFO(dev)->gen < 9) { 15001 - DRM_DEBUG("unsupported pixel format: %s\n", 15002 - drm_get_format_name(mode_cmd->pixel_format)); 14997 + format_name = drm_get_format_name(mode_cmd->pixel_format); 14998 + DRM_DEBUG("unsupported pixel format: %s\n", format_name); 14999 + kfree(format_name); 15003 15000 return -EINVAL; 15004 15001 } 15005 15002 break; ··· 15009 15002 case DRM_FORMAT_XRGB2101010: 15010 15003 case DRM_FORMAT_XBGR2101010: 15011 15004 if (INTEL_INFO(dev)->gen < 4) { 15012 - DRM_DEBUG("unsupported pixel format: %s\n", 15013 - drm_get_format_name(mode_cmd->pixel_format)); 15005 + format_name = drm_get_format_name(mode_cmd->pixel_format); 15006 + DRM_DEBUG("unsupported pixel format: %s\n", format_name); 15007 + kfree(format_name); 15014 15008 return -EINVAL; 15015 15009 } 15016 15010 break; 15017 15011 case DRM_FORMAT_ABGR2101010: 15018 15012 if (!IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev)) { 15019 - DRM_DEBUG("unsupported pixel format: %s\n", 15020 - drm_get_format_name(mode_cmd->pixel_format)); 15013 + format_name = drm_get_format_name(mode_cmd->pixel_format); 15014 + DRM_DEBUG("unsupported pixel format: %s\n", format_name); 15015 + kfree(format_name); 15021 15016 return -EINVAL; 15022 15017 } 15023 15018 break; ··· 15028 15019 case DRM_FORMAT_YVYU: 15029 15020 case DRM_FORMAT_VYUY: 15030 15021 if (INTEL_INFO(dev)->gen < 5) { 15031 - DRM_DEBUG("unsupported pixel format: %s\n", 15032 - drm_get_format_name(mode_cmd->pixel_format)); 15022 + format_name = drm_get_format_name(mode_cmd->pixel_format); 15023 + DRM_DEBUG("unsupported pixel format: %s\n", format_name); 15024 + kfree(format_name); 15033 15025 return -EINVAL; 15034 15026 } 15035 15027 break; 15036 15028 default: 15037 - DRM_DEBUG("unsupported pixel format: %s\n", 15038 - drm_get_format_name(mode_cmd->pixel_format)); 15029 + format_name = drm_get_format_name(mode_cmd->pixel_format); 15030 + DRM_DEBUG("unsupported pixel format: %s\n", format_name); 15031 + kfree(format_name); 15039 15032 return -EINVAL; 15040 15033 } 15041 15034
+2 -2
drivers/gpu/drm/i915/intel_drv.h
··· 1225 1225 void intel_finish_page_flip_mmio(struct drm_i915_private *dev_priv, int pipe); 1226 1226 void intel_check_page_flip(struct drm_i915_private *dev_priv, int pipe); 1227 1227 int intel_prepare_plane_fb(struct drm_plane *plane, 1228 - const struct drm_plane_state *new_state); 1228 + struct drm_plane_state *new_state); 1229 1229 void intel_cleanup_plane_fb(struct drm_plane *plane, 1230 - const struct drm_plane_state *old_state); 1230 + struct drm_plane_state *old_state); 1231 1231 int intel_plane_atomic_get_property(struct drm_plane *plane, 1232 1232 const struct drm_plane_state *state, 1233 1233 struct drm_property *property,
+3 -2
drivers/gpu/drm/i915/intel_guc_fwif.h
··· 155 155 * 156 156 * +-------------------------------+ 157 157 * | guc_css_header | 158 + * | | 158 159 * | contains major/minor version | 159 160 * +-------------------------------+ 160 161 * | uCode | ··· 177 176 * 178 177 * 1. Header, uCode and RSA are must-have components. 179 178 * 2. All firmware components, if they present, are in the sequence illustrated 180 - * in the layout table above. 179 + * in the layout table above. 181 180 * 3. Length info of each component can be found in header, in dwords. 182 181 * 4. Modulus and exponent key are not required by driver. They may not appear 183 - * in fw. So driver will load a truncated firmware in this case. 182 + * in fw. So driver will load a truncated firmware in this case. 184 183 */ 185 184 186 185 struct guc_css_header {
-11
drivers/gpu/drm/i915/intel_lvds.c
··· 1054 1054 } 1055 1055 lvds_connector->base.edid = edid; 1056 1056 1057 - if (IS_ERR_OR_NULL(edid)) { 1058 - /* Didn't get an EDID, so 1059 - * Set wide sync ranges so we get all modes 1060 - * handed to valid_mode for checking 1061 - */ 1062 - connector->display_info.min_vfreq = 0; 1063 - connector->display_info.max_vfreq = 200; 1064 - connector->display_info.min_hfreq = 0; 1065 - connector->display_info.max_hfreq = 200; 1066 - } 1067 - 1068 1057 list_for_each_entry(scan, &connector->probed_modes, head) { 1069 1058 if (scan->type & DRM_MODE_TYPE_PREFERRED) { 1070 1059 DRM_DEBUG_KMS("using preferred mode from EDID: ");
+3 -1
drivers/gpu/drm/mgag200/mgag200_fb.c
··· 183 183 } 184 184 185 185 sysram = vmalloc(size); 186 - if (!sysram) 186 + if (!sysram) { 187 + ret = -ENOMEM; 187 188 goto err_sysram; 189 + } 188 190 189 191 info = drm_fb_helper_alloc_fbi(helper); 190 192 if (IS_ERR(info)) {
+2 -2
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
··· 99 99 }; 100 100 101 101 static int mdp4_plane_prepare_fb(struct drm_plane *plane, 102 - const struct drm_plane_state *new_state) 102 + struct drm_plane_state *new_state) 103 103 { 104 104 struct mdp4_plane *mdp4_plane = to_mdp4_plane(plane); 105 105 struct mdp4_kms *mdp4_kms = get_kms(plane); ··· 113 113 } 114 114 115 115 static void mdp4_plane_cleanup_fb(struct drm_plane *plane, 116 - const struct drm_plane_state *old_state) 116 + struct drm_plane_state *old_state) 117 117 { 118 118 struct mdp4_plane *mdp4_plane = to_mdp4_plane(plane); 119 119 struct mdp4_kms *mdp4_kms = get_kms(plane);
+2 -2
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
··· 250 250 }; 251 251 252 252 static int mdp5_plane_prepare_fb(struct drm_plane *plane, 253 - const struct drm_plane_state *new_state) 253 + struct drm_plane_state *new_state) 254 254 { 255 255 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane); 256 256 struct mdp5_kms *mdp5_kms = get_kms(plane); ··· 264 264 } 265 265 266 266 static void mdp5_plane_cleanup_fb(struct drm_plane *plane, 267 - const struct drm_plane_state *old_state) 267 + struct drm_plane_state *old_state) 268 268 { 269 269 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane); 270 270 struct mdp5_kms *mdp5_kms = get_kms(plane);
+2 -2
drivers/gpu/drm/omapdrm/omap_plane.c
··· 60 60 } 61 61 62 62 static int omap_plane_prepare_fb(struct drm_plane *plane, 63 - const struct drm_plane_state *new_state) 63 + struct drm_plane_state *new_state) 64 64 { 65 65 if (!new_state->fb) 66 66 return 0; ··· 69 69 } 70 70 71 71 static void omap_plane_cleanup_fb(struct drm_plane *plane, 72 - const struct drm_plane_state *old_state) 72 + struct drm_plane_state *old_state) 73 73 { 74 74 if (old_state->fb) 75 75 omap_framebuffer_unpin(old_state->fb);
+8 -4
drivers/gpu/drm/radeon/atombios_crtc.c
··· 1154 1154 u32 tmp, viewport_w, viewport_h; 1155 1155 int r; 1156 1156 bool bypass_lut = false; 1157 + char *format_name; 1157 1158 1158 1159 /* no fb bound */ 1159 1160 if (!atomic && !crtc->primary->fb) { ··· 1258 1257 bypass_lut = true; 1259 1258 break; 1260 1259 default: 1261 - DRM_ERROR("Unsupported screen format %s\n", 1262 - drm_get_format_name(target_fb->pixel_format)); 1260 + format_name = drm_get_format_name(target_fb->pixel_format); 1261 + DRM_ERROR("Unsupported screen format %s\n", format_name); 1262 + kfree(format_name); 1263 1263 return -EINVAL; 1264 1264 } 1265 1265 ··· 1471 1469 u32 viewport_w, viewport_h; 1472 1470 int r; 1473 1471 bool bypass_lut = false; 1472 + char *format_name; 1474 1473 1475 1474 /* no fb bound */ 1476 1475 if (!atomic && !crtc->primary->fb) { ··· 1561 1558 bypass_lut = true; 1562 1559 break; 1563 1560 default: 1564 - DRM_ERROR("Unsupported screen format %s\n", 1565 - drm_get_format_name(target_fb->pixel_format)); 1561 + format_name = drm_get_format_name(target_fb->pixel_format); 1562 + DRM_ERROR("Unsupported screen format %s\n", format_name); 1563 + kfree(format_name); 1566 1564 return -EINVAL; 1567 1565 } 1568 1566
-1
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
··· 445 445 .remove = rockchip_dp_remove, 446 446 .driver = { 447 447 .name = "rockchip-dp", 448 - .owner = THIS_MODULE, 449 448 .pm = &rockchip_dp_pm_ops, 450 449 .of_match_table = of_match_ptr(rockchip_dp_dt_ids), 451 450 },
+33 -26
drivers/gpu/drm/rockchip/rockchip_drm_vop.c
··· 238 238 case DRM_FORMAT_NV24: 239 239 return VOP_FMT_YUV444SP; 240 240 default: 241 - DRM_ERROR("unsupport format[%08x]\n", format); 241 + DRM_ERROR("unsupported format[%08x]\n", format); 242 242 return -EINVAL; 243 243 } 244 244 } ··· 315 315 int vskiplines = 0; 316 316 317 317 if (dst_w > 3840) { 318 - DRM_ERROR("Maximum destination width (3840) exceeded\n"); 318 + DRM_DEV_ERROR(vop->dev, "Maximum dst width (3840) exceeded\n"); 319 319 return; 320 320 } 321 321 ··· 353 353 VOP_SCL_SET_EXT(vop, win, lb_mode, lb_mode); 354 354 if (lb_mode == LB_RGB_3840X2) { 355 355 if (yrgb_ver_scl_mode != SCALE_NONE) { 356 - DRM_ERROR("ERROR : not allow yrgb ver scale\n"); 356 + DRM_DEV_ERROR(vop->dev, "not allow yrgb ver scale\n"); 357 357 return; 358 358 } 359 359 if (cbcr_ver_scl_mode != SCALE_NONE) { 360 - DRM_ERROR("ERROR : not allow cbcr ver scale\n"); 360 + DRM_DEV_ERROR(vop->dev, "not allow cbcr ver scale\n"); 361 361 return; 362 362 } 363 363 vsu_mode = SCALE_UP_BIL; ··· 428 428 spin_unlock_irqrestore(&vop->irq_lock, flags); 429 429 } 430 430 431 - static void vop_enable(struct drm_crtc *crtc) 431 + static int vop_enable(struct drm_crtc *crtc) 432 432 { 433 433 struct vop *vop = to_vop(crtc); 434 434 int ret; ··· 436 436 ret = pm_runtime_get_sync(vop->dev); 437 437 if (ret < 0) { 438 438 dev_err(vop->dev, "failed to get pm runtime: %d\n", ret); 439 - return; 439 + goto err_put_pm_runtime; 440 440 } 441 441 442 442 ret = clk_enable(vop->hclk); 443 - if (ret < 0) { 444 - dev_err(vop->dev, "failed to enable hclk - %d\n", ret); 445 - return; 446 - } 443 + if (WARN_ON(ret < 0)) 444 + goto err_put_pm_runtime; 447 445 448 446 ret = clk_enable(vop->dclk); 449 - if (ret < 0) { 450 - dev_err(vop->dev, "failed to enable dclk - %d\n", ret); 447 + if (WARN_ON(ret < 0)) 451 448 goto err_disable_hclk; 452 - } 453 449 454 450 ret = clk_enable(vop->aclk); 455 - if (ret < 0) { 456 - dev_err(vop->dev, "failed to enable aclk - %d\n", ret); 451 + if (WARN_ON(ret < 0)) 457 452 goto err_disable_dclk; 458 - } 459 453 460 454 /* 461 455 * Slave iommu shares power, irq and clock with vop. It was associated ··· 479 485 480 486 drm_crtc_vblank_on(crtc); 481 487 482 - return; 488 + return 0; 483 489 484 490 err_disable_aclk: 485 491 clk_disable(vop->aclk); ··· 487 493 clk_disable(vop->dclk); 488 494 err_disable_hclk: 489 495 clk_disable(vop->hclk); 496 + err_put_pm_runtime: 497 + pm_runtime_put_sync(vop->dev); 498 + return ret; 490 499 } 491 500 492 501 static void vop_crtc_disable(struct drm_crtc *crtc) ··· 564 567 } 565 568 566 569 static int vop_plane_prepare_fb(struct drm_plane *plane, 567 - const struct drm_plane_state *new_state) 570 + struct drm_plane_state *new_state) 568 571 { 569 572 if (plane->state->fb) 570 573 drm_framebuffer_reference(plane->state->fb); ··· 573 576 } 574 577 575 578 static void vop_plane_cleanup_fb(struct drm_plane *plane, 576 - const struct drm_plane_state *old_state) 579 + struct drm_plane_state *old_state) 577 580 { 578 581 if (old_state->fb) 579 582 drm_framebuffer_unreference(old_state->fb); ··· 909 912 u16 vact_st = adjusted_mode->vtotal - adjusted_mode->vsync_start; 910 913 u16 vact_end = vact_st + vdisplay; 911 914 uint32_t val; 915 + int ret; 912 916 913 917 WARN_ON(vop->event); 914 918 915 - vop_enable(crtc); 919 + ret = vop_enable(crtc); 920 + if (ret) { 921 + DRM_DEV_ERROR(vop->dev, "Failed to enable vop (%d)\n", ret); 922 + return; 923 + } 924 + 916 925 /* 917 926 * If dclk rate is zero, mean that scanout is stop, 918 927 * we don't need wait any more. ··· 973 970 VOP_CTRL_SET(vop, mipi_en, 1); 974 971 break; 975 972 default: 976 - DRM_ERROR("unsupport connector_type[%d]\n", s->output_type); 973 + DRM_DEV_ERROR(vop->dev, "unsupported connector_type [%d]\n", 974 + s->output_type); 977 975 } 978 976 VOP_CTRL_SET(vop, out_mode, s->output_mode); 979 977 ··· 1158 1154 1159 1155 /* Unhandled irqs are spurious. */ 1160 1156 if (active_irqs) 1161 - DRM_ERROR("Unknown VOP IRQs: %#02x\n", active_irqs); 1157 + DRM_DEV_ERROR(vop->dev, "Unknown VOP IRQs: %#02x\n", 1158 + active_irqs); 1162 1159 1163 1160 return ret; 1164 1161 } ··· 1194 1189 win_data->phy->nformats, 1195 1190 win_data->type, NULL); 1196 1191 if (ret) { 1197 - DRM_ERROR("failed to initialize plane\n"); 1192 + DRM_DEV_ERROR(vop->dev, "failed to init plane %d\n", 1193 + ret); 1198 1194 goto err_cleanup_planes; 1199 1195 } 1200 1196 ··· 1233 1227 win_data->phy->nformats, 1234 1228 win_data->type, NULL); 1235 1229 if (ret) { 1236 - DRM_ERROR("failed to initialize overlay plane\n"); 1230 + DRM_DEV_ERROR(vop->dev, "failed to init overlay %d\n", 1231 + ret); 1237 1232 goto err_cleanup_crtc; 1238 1233 } 1239 1234 drm_plane_helper_add(&vop_win->base, &plane_helper_funcs); ··· 1242 1235 1243 1236 port = of_get_child_by_name(dev->of_node, "port"); 1244 1237 if (!port) { 1245 - DRM_ERROR("no port node found in %s\n", 1246 - dev->of_node->full_name); 1238 + DRM_DEV_ERROR(vop->dev, "no port node found in %s\n", 1239 + dev->of_node->full_name); 1247 1240 ret = -ENOENT; 1248 1241 goto err_cleanup_crtc; 1249 1242 }
-1
drivers/gpu/drm/rockchip/rockchip_vop_reg.c
··· 305 305 .remove = vop_remove, 306 306 .driver = { 307 307 .name = "rockchip-vop", 308 - .owner = THIS_MODULE, 309 308 .of_match_table = of_match_ptr(vop_driver_dt_match), 310 309 }, 311 310 };
+3 -9
drivers/gpu/drm/savage/savage_state.c
··· 1001 1001 cmdbuf->cmd_addr = kcmd_addr; 1002 1002 } 1003 1003 if (cmdbuf->vb_size) { 1004 - kvb_addr = kmalloc(cmdbuf->vb_size, GFP_KERNEL); 1005 - if (kvb_addr == NULL) { 1006 - ret = -ENOMEM; 1007 - goto done; 1008 - } 1009 - 1010 - if (copy_from_user(kvb_addr, cmdbuf->vb_addr, 1011 - cmdbuf->vb_size)) { 1012 - ret = -EFAULT; 1004 + kvb_addr = memdup_user(cmdbuf->vb_addr, cmdbuf->vb_size); 1005 + if (IS_ERR(kvb_addr)) { 1006 + ret = PTR_ERR(kvb_addr); 1013 1007 goto done; 1014 1008 } 1015 1009 cmdbuf->vb_addr = kvb_addr;
+1 -1
drivers/gpu/drm/sti/sti_drv.c
··· 282 282 }; 283 283 284 284 static struct drm_driver sti_driver = { 285 - .driver_features = DRIVER_HAVE_IRQ | DRIVER_MODESET | 285 + .driver_features = DRIVER_MODESET | 286 286 DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC, 287 287 .gem_free_object_unlocked = drm_gem_cma_free_object, 288 288 .gem_vm_ops = &drm_gem_cma_vm_ops,
-17
drivers/gpu/drm/tegra/dc.c
··· 480 480 .atomic_destroy_state = tegra_plane_atomic_destroy_state, 481 481 }; 482 482 483 - static int tegra_plane_prepare_fb(struct drm_plane *plane, 484 - const struct drm_plane_state *new_state) 485 - { 486 - return 0; 487 - } 488 - 489 - static void tegra_plane_cleanup_fb(struct drm_plane *plane, 490 - const struct drm_plane_state *old_fb) 491 - { 492 - } 493 - 494 483 static int tegra_plane_state_add(struct tegra_plane *plane, 495 484 struct drm_plane_state *state) 496 485 { ··· 613 624 } 614 625 615 626 static const struct drm_plane_helper_funcs tegra_primary_plane_helper_funcs = { 616 - .prepare_fb = tegra_plane_prepare_fb, 617 - .cleanup_fb = tegra_plane_cleanup_fb, 618 627 .atomic_check = tegra_plane_atomic_check, 619 628 .atomic_update = tegra_plane_atomic_update, 620 629 .atomic_disable = tegra_plane_atomic_disable, ··· 783 796 }; 784 797 785 798 static const struct drm_plane_helper_funcs tegra_cursor_plane_helper_funcs = { 786 - .prepare_fb = tegra_plane_prepare_fb, 787 - .cleanup_fb = tegra_plane_cleanup_fb, 788 799 .atomic_check = tegra_cursor_atomic_check, 789 800 .atomic_update = tegra_cursor_atomic_update, 790 801 .atomic_disable = tegra_cursor_atomic_disable, ··· 851 866 }; 852 867 853 868 static const struct drm_plane_helper_funcs tegra_overlay_plane_helper_funcs = { 854 - .prepare_fb = tegra_plane_prepare_fb, 855 - .cleanup_fb = tegra_plane_cleanup_fb, 856 869 .atomic_check = tegra_plane_atomic_check, 857 870 .atomic_update = tegra_plane_atomic_update, 858 871 .atomic_disable = tegra_plane_atomic_disable,
-3
drivers/gpu/drm/udl/udl_connector.c
··· 150 150 drm_connector_register(connector); 151 151 drm_mode_connector_attach_encoder(connector, encoder); 152 152 153 - drm_object_attach_property(&connector->base, 154 - dev->mode_config.dirty_info_property, 155 - 1); 156 153 return 0; 157 154 }
+25
drivers/gpu/drm/udl/udl_main.c
··· 16 16 /* -BULK_SIZE as per usb-skeleton. Can we get full page and avoid overhead? */ 17 17 #define BULK_SIZE 512 18 18 19 + #define NR_USB_REQUEST_CHANNEL 0x12 20 + 19 21 #define MAX_TRANSFER (PAGE_SIZE*16 - BULK_SIZE) 20 22 #define WRITES_IN_FLIGHT (4) 21 23 #define MAX_VENDOR_DESCRIPTOR_SIZE 256 ··· 90 88 success: 91 89 kfree(buf); 92 90 return true; 91 + } 92 + 93 + /* 94 + * Need to ensure a channel is selected before submitting URBs 95 + */ 96 + static int udl_select_std_channel(struct udl_device *udl) 97 + { 98 + int ret; 99 + u8 set_def_chn[] = {0x57, 0xCD, 0xDC, 0xA7, 100 + 0x1C, 0x88, 0x5E, 0x15, 101 + 0x60, 0xFE, 0xC6, 0x97, 102 + 0x16, 0x3D, 0x47, 0xF2}; 103 + 104 + ret = usb_control_msg(udl->udev, 105 + usb_sndctrlpipe(udl->udev, 0), 106 + NR_USB_REQUEST_CHANNEL, 107 + (USB_DIR_OUT | USB_TYPE_VENDOR), 0, 0, 108 + set_def_chn, sizeof(set_def_chn), 109 + USB_CTRL_SET_TIMEOUT); 110 + return ret < 0 ? ret : 0; 93 111 } 94 112 95 113 static void udl_release_urb_work(struct work_struct *work) ··· 322 300 DRM_ERROR("firmware not recognized. Assume incompatible device\n"); 323 301 goto err; 324 302 } 303 + 304 + if (udl_select_std_channel(udl)) 305 + DRM_ERROR("Selecting channel failed\n"); 325 306 326 307 if (!udl_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) { 327 308 DRM_ERROR("udl_alloc_urb_list failed\n");
-2
drivers/gpu/drm/udl/udl_modeset.c
··· 441 441 442 442 dev->mode_config.funcs = &udl_mode_funcs; 443 443 444 - drm_mode_create_dirty_info_property(dev); 445 - 446 444 udl_crtc_init(dev); 447 445 448 446 encoder = udl_encoder_init(dev);
-2
drivers/gpu/drm/vc4/vc4_plane.c
··· 735 735 } 736 736 737 737 static const struct drm_plane_helper_funcs vc4_plane_helper_funcs = { 738 - .prepare_fb = NULL, 739 - .cleanup_fb = NULL, 740 738 .atomic_check = vc4_plane_atomic_check, 741 739 .atomic_update = vc4_plane_atomic_update, 742 740 };
+4 -9
drivers/gpu/drm/virtio/virtgpu_ioctl.c
··· 152 152 if (ret) 153 153 goto out_free; 154 154 155 - buf = kmalloc(exbuf->size, GFP_KERNEL); 156 - if (!buf) { 157 - ret = -ENOMEM; 158 - goto out_unresv; 159 - } 160 - if (copy_from_user(buf, (void __user *)(uintptr_t)exbuf->command, 161 - exbuf->size)) { 162 - kfree(buf); 163 - ret = -EFAULT; 155 + buf = memdup_user((void __user *)(uintptr_t)exbuf->command, 156 + exbuf->size); 157 + if (IS_ERR(buf)) { 158 + ret = PTR_ERR(buf); 164 159 goto out_unresv; 165 160 } 166 161 virtio_gpu_cmd_submit(vgdev, buf, exbuf->size,
-9
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
··· 377 377 drm_mode_crtc_set_gamma_size(crtc, 256); 378 378 379 379 drm_object_attach_property(&connector->base, 380 - dev->mode_config.dirty_info_property, 381 - 1); 382 - drm_object_attach_property(&connector->base, 383 380 dev_priv->hotplug_mode_update_property, 1); 384 381 drm_object_attach_property(&connector->base, 385 382 dev->mode_config.suggested_x_property, 0); ··· 418 421 if (ret != 0) 419 422 goto err_free; 420 423 421 - ret = drm_mode_create_dirty_info_property(dev); 422 - if (ret != 0) 423 - goto err_vblank_cleanup; 424 - 425 424 vmw_kms_create_implicit_placement_property(dev_priv, true); 426 425 427 426 if (dev_priv->capabilities & SVGA_CAP_MULTIMON) ··· 432 439 433 440 return 0; 434 441 435 - err_vblank_cleanup: 436 - drm_vblank_cleanup(dev); 437 442 err_free: 438 443 kfree(dev_priv->ldu_priv); 439 444 dev_priv->ldu_priv = NULL;
-11
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
··· 538 538 drm_mode_crtc_set_gamma_size(crtc, 256); 539 539 540 540 drm_object_attach_property(&connector->base, 541 - dev->mode_config.dirty_info_property, 542 - 1); 543 - drm_object_attach_property(&connector->base, 544 541 dev_priv->hotplug_mode_update_property, 1); 545 542 drm_object_attach_property(&connector->base, 546 543 dev->mode_config.suggested_x_property, 0); ··· 571 574 if (unlikely(ret != 0)) 572 575 return ret; 573 576 574 - ret = drm_mode_create_dirty_info_property(dev); 575 - if (unlikely(ret != 0)) 576 - goto err_vblank_cleanup; 577 - 578 577 vmw_kms_create_implicit_placement_property(dev_priv, false); 579 578 580 579 for (i = 0; i < VMWGFX_NUM_DISPLAY_UNITS; ++i) ··· 581 588 DRM_INFO("Screen Objects Display Unit initialized\n"); 582 589 583 590 return 0; 584 - 585 - err_vblank_cleanup: 586 - drm_vblank_cleanup(dev); 587 - return ret; 588 591 } 589 592 590 593 int vmw_kms_sou_close_display(struct vmw_private *dev_priv)
-7
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
··· 1131 1131 drm_mode_crtc_set_gamma_size(crtc, 256); 1132 1132 1133 1133 drm_object_attach_property(&connector->base, 1134 - dev->mode_config.dirty_info_property, 1135 - 1); 1136 - drm_object_attach_property(&connector->base, 1137 1134 dev_priv->hotplug_mode_update_property, 1); 1138 1135 drm_object_attach_property(&connector->base, 1139 1136 dev->mode_config.suggested_x_property, 0); ··· 1198 1201 ret = drm_vblank_init(dev, VMWGFX_NUM_DISPLAY_UNITS); 1199 1202 if (unlikely(ret != 0)) 1200 1203 return ret; 1201 - 1202 - ret = drm_mode_create_dirty_info_property(dev); 1203 - if (unlikely(ret != 0)) 1204 - goto err_vblank_cleanup; 1205 1204 1206 1205 dev_priv->active_display_unit = vmw_du_screen_target; 1207 1206
+108 -2
drivers/gpu/vga/vgaarb.c
··· 131 131 return NULL; 132 132 } 133 133 134 - /* Returns the default VGA device (vgacon's babe) */ 134 + /** 135 + * vga_default_device - return the default VGA device, for vgacon 136 + * 137 + * This can be defined by the platform. The default implementation 138 + * is rather dumb and will probably only work properly on single 139 + * vga card setups and/or x86 platforms. 140 + * 141 + * If your VGA default device is not PCI, you'll have to return 142 + * NULL here. In this case, I assume it will not conflict with 143 + * any PCI card. If this is not true, I'll have to define two archs 144 + * hooks for enabling/disabling the VGA default device if that is 145 + * possible. This may be a problem with real _ISA_ VGA cards, in 146 + * addition to a PCI one. I don't know at this point how to deal 147 + * with that card. Can theirs IOs be disabled at all ? If not, then 148 + * I suppose it's a matter of having the proper arch hook telling 149 + * us about it, so we basically never allow anybody to succeed a 150 + * vga_get()... 151 + */ 135 152 struct pci_dev *vga_default_device(void) 136 153 { 137 154 return vga_default; ··· 373 356 wake_up_all(&vga_wait_queue); 374 357 } 375 358 359 + /** 360 + * vga_get - acquire & locks VGA resources 361 + * @pdev: pci device of the VGA card or NULL for the system default 362 + * @rsrc: bit mask of resources to acquire and lock 363 + * @interruptible: blocking should be interruptible by signals ? 364 + * 365 + * This function acquires VGA resources for the given card and mark those 366 + * resources locked. If the resource requested are "normal" (and not legacy) 367 + * resources, the arbiter will first check whether the card is doing legacy 368 + * decoding for that type of resource. If yes, the lock is "converted" into a 369 + * legacy resource lock. 370 + * 371 + * The arbiter will first look for all VGA cards that might conflict and disable 372 + * their IOs and/or Memory access, including VGA forwarding on P2P bridges if 373 + * necessary, so that the requested resources can be used. Then, the card is 374 + * marked as locking these resources and the IO and/or Memory accesses are 375 + * enabled on the card (including VGA forwarding on parent P2P bridges if any). 376 + * 377 + * This function will block if some conflicting card is already locking one of 378 + * the required resources (or any resource on a different bus segment, since P2P 379 + * bridges don't differentiate VGA memory and IO afaik). You can indicate 380 + * whether this blocking should be interruptible by a signal (for userland 381 + * interface) or not. 382 + * 383 + * Must not be called at interrupt time or in atomic context. If the card 384 + * already owns the resources, the function succeeds. Nested calls are 385 + * supported (a per-resource counter is maintained) 386 + * 387 + * On success, release the VGA resource again with vga_put(). 388 + * 389 + * Returns: 390 + * 391 + * 0 on success, negative error code on failure. 392 + */ 376 393 int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible) 377 394 { 378 395 struct vga_device *vgadev, *conflict; ··· 459 408 } 460 409 EXPORT_SYMBOL(vga_get); 461 410 411 + /** 412 + * vga_tryget - try to acquire & lock legacy VGA resources 413 + * @pdev: pci devivce of VGA card or NULL for system default 414 + * @rsrc: bit mask of resources to acquire and lock 415 + * 416 + * This function performs the same operation as vga_get(), but will return an 417 + * error (-EBUSY) instead of blocking if the resources are already locked by 418 + * another card. It can be called in any context 419 + * 420 + * On success, release the VGA resource again with vga_put(). 421 + * 422 + * Returns: 423 + * 424 + * 0 on success, negative error code on failure. 425 + */ 462 426 int vga_tryget(struct pci_dev *pdev, unsigned int rsrc) 463 427 { 464 428 struct vga_device *vgadev; ··· 501 435 } 502 436 EXPORT_SYMBOL(vga_tryget); 503 437 438 + /** 439 + * vga_put - release lock on legacy VGA resources 440 + * @pdev: pci device of VGA card or NULL for system default 441 + * @rsrc: but mask of resource to release 442 + * 443 + * This fuction releases resources previously locked by vga_get() or 444 + * vga_tryget(). The resources aren't disabled right away, so that a subsequence 445 + * vga_get() on the same card will succeed immediately. Resources have a 446 + * counter, so locks are only released if the counter reaches 0. 447 + */ 504 448 void vga_put(struct pci_dev *pdev, unsigned int rsrc) 505 449 { 506 450 struct vga_device *vgadev; ··· 792 716 } 793 717 EXPORT_SYMBOL(vga_set_legacy_decoding); 794 718 795 - /* call with NULL to unregister */ 719 + /** 720 + * vga_client_register - register or unregister a VGA arbitration client 721 + * @pdev: pci device of the VGA client 722 + * @cookie: client cookie to be used in callbacks 723 + * @irq_set_state: irq state change callback 724 + * @set_vga_decode: vga decode change callback 725 + * 726 + * Clients have two callback mechanisms they can use. 727 + * 728 + * @irq_set_state callback: If a client can't disable its GPUs VGA 729 + * resources, then we need to be able to ask it to turn off its irqs when we 730 + * turn off its mem and io decoding. 731 + * 732 + * @set_vga_decode callback: If a client can disable its GPU VGA resource, it 733 + * will get a callback from this to set the encode/decode state. 734 + * 735 + * Rationale: we cannot disable VGA decode resources unconditionally some single 736 + * GPU laptops seem to require ACPI or BIOS access to the VGA registers to 737 + * control things like backlights etc. Hopefully newer multi-GPU laptops do 738 + * something saner, and desktops won't have any special ACPI for this. The 739 + * driver will get a callback when VGA arbitration is first used by userspace 740 + * since some older X servers have issues. 741 + * 742 + * This function does not check whether a client for @pdev has been registered 743 + * already. 744 + * 745 + * To unregister just call this function with @irq_set_state and @set_vga_decode 746 + * both set to NULL for the same @pdev as originally used to register them. 747 + * 748 + * Returns: 0 on success, -1 on failure 749 + */ 796 750 int vga_client_register(struct pci_dev *pdev, void *cookie, 797 751 void (*irq_set_state)(void *cookie, bool state), 798 752 unsigned int (*set_vga_decode)(void *cookie,
+87 -59
include/drm/drmP.h
··· 127 127 * run-time by echoing the debug value in its sysfs node: 128 128 * # echo 0xf > /sys/module/drm/parameters/debug 129 129 */ 130 + #define DRM_UT_NONE 0x00 130 131 #define DRM_UT_CORE 0x01 131 132 #define DRM_UT_DRIVER 0x02 132 133 #define DRM_UT_KMS 0x04 ··· 135 134 #define DRM_UT_ATOMIC 0x10 136 135 #define DRM_UT_VBL 0x20 137 136 138 - extern __printf(2, 3) 139 - void drm_ut_debug_printk(const char *function_name, 140 - const char *format, ...); 141 - extern __printf(1, 2) 142 - void drm_err(const char *format, ...); 137 + extern __printf(6, 7) 138 + void drm_dev_printk(const struct device *dev, const char *level, 139 + unsigned int category, const char *function_name, 140 + const char *prefix, const char *format, ...); 141 + 142 + extern __printf(5, 6) 143 + void drm_printk(const char *level, unsigned int category, 144 + const char *function_name, const char *prefix, 145 + const char *format, ...); 143 146 144 147 /***********************************************************************/ 145 148 /** \name DRM template customization defaults */ ··· 174 169 * \param fmt printf() like format string. 175 170 * \param arg arguments 176 171 */ 177 - #define DRM_ERROR(fmt, ...) \ 178 - drm_err(fmt, ##__VA_ARGS__) 172 + #define DRM_DEV_ERROR(dev, fmt, ...) \ 173 + drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\ 174 + fmt, ##__VA_ARGS__) 175 + #define DRM_ERROR(fmt, ...) \ 176 + drm_printk(KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*", fmt, \ 177 + ##__VA_ARGS__) 179 178 180 179 /** 181 180 * Rate limited error output. Like DRM_ERROR() but won't flood the log. ··· 187 178 * \param fmt printf() like format string. 188 179 * \param arg arguments 189 180 */ 190 - #define DRM_ERROR_RATELIMITED(fmt, ...) \ 181 + #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \ 191 182 ({ \ 192 183 static DEFINE_RATELIMIT_STATE(_rs, \ 193 184 DEFAULT_RATELIMIT_INTERVAL, \ 194 185 DEFAULT_RATELIMIT_BURST); \ 195 186 \ 196 187 if (__ratelimit(&_rs)) \ 197 - drm_err(fmt, ##__VA_ARGS__); \ 188 + DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \ 198 189 }) 190 + #define DRM_ERROR_RATELIMITED(fmt, ...) \ 191 + DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) 199 192 200 - #define DRM_INFO(fmt, ...) \ 201 - printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) 193 + #define DRM_DEV_INFO(dev, fmt, ...) \ 194 + drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \ 195 + ##__VA_ARGS__) 196 + #define DRM_INFO(fmt, ...) \ 197 + drm_printk(KERN_INFO, DRM_UT_NONE, __func__, "", fmt, ##__VA_ARGS__) 202 198 203 - #define DRM_INFO_ONCE(fmt, ...) \ 204 - printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__) 199 + #define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ 200 + ({ \ 201 + static bool __print_once __read_mostly; \ 202 + if (!__print_once) { \ 203 + __print_once = true; \ 204 + DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \ 205 + } \ 206 + }) 207 + #define DRM_INFO_ONCE(fmt, ...) DRM_DEV_INFO_ONCE(NULL, fmt, ##__VA_ARGS__) 205 208 206 209 /** 207 210 * Debug output. ··· 221 200 * \param fmt printf() like format string. 222 201 * \param arg arguments 223 202 */ 203 + #define DRM_DEV_DEBUG(dev, fmt, args...) \ 204 + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \ 205 + ##args) 224 206 #define DRM_DEBUG(fmt, args...) \ 225 - do { \ 226 - if (unlikely(drm_debug & DRM_UT_CORE)) \ 227 - drm_ut_debug_printk(__func__, fmt, ##args); \ 228 - } while (0) 207 + drm_printk(KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, ##args) 229 208 209 + #define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \ 210 + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \ 211 + fmt, ##args) 230 212 #define DRM_DEBUG_DRIVER(fmt, args...) \ 231 - do { \ 232 - if (unlikely(drm_debug & DRM_UT_DRIVER)) \ 233 - drm_ut_debug_printk(__func__, fmt, ##args); \ 234 - } while (0) 235 - #define DRM_DEBUG_KMS(fmt, args...) \ 236 - do { \ 237 - if (unlikely(drm_debug & DRM_UT_KMS)) \ 238 - drm_ut_debug_printk(__func__, fmt, ##args); \ 239 - } while (0) 240 - #define DRM_DEBUG_PRIME(fmt, args...) \ 241 - do { \ 242 - if (unlikely(drm_debug & DRM_UT_PRIME)) \ 243 - drm_ut_debug_printk(__func__, fmt, ##args); \ 244 - } while (0) 245 - #define DRM_DEBUG_ATOMIC(fmt, args...) \ 246 - do { \ 247 - if (unlikely(drm_debug & DRM_UT_ATOMIC)) \ 248 - drm_ut_debug_printk(__func__, fmt, ##args); \ 249 - } while (0) 250 - #define DRM_DEBUG_VBL(fmt, args...) \ 251 - do { \ 252 - if (unlikely(drm_debug & DRM_UT_VBL)) \ 253 - drm_ut_debug_printk(__func__, fmt, ##args); \ 254 - } while (0) 213 + drm_printk(KERN_DEBUG, DRM_UT_DRIVER, __func__, "", fmt, ##args) 255 214 256 - #define _DRM_DEFINE_DEBUG_RATELIMITED(level, fmt, args...) \ 257 - do { \ 258 - if (unlikely(drm_debug & DRM_UT_ ## level)) { \ 259 - static DEFINE_RATELIMIT_STATE( \ 260 - _rs, \ 261 - DEFAULT_RATELIMIT_INTERVAL, \ 262 - DEFAULT_RATELIMIT_BURST); \ 263 - \ 264 - if (__ratelimit(&_rs)) { \ 265 - drm_ut_debug_printk(__func__, fmt, \ 266 - ##args); \ 267 - } \ 268 - } \ 269 - } while (0) 215 + #define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \ 216 + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \ 217 + ##args) 218 + #define DRM_DEBUG_KMS(fmt, args...) \ 219 + drm_printk(KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, ##args) 220 + 221 + #define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \ 222 + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \ 223 + fmt, ##args) 224 + #define DRM_DEBUG_PRIME(fmt, args...) \ 225 + drm_printk(KERN_DEBUG, DRM_UT_PRIME, __func__, "", fmt, ##args) 226 + 227 + #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \ 228 + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \ 229 + fmt, ##args) 230 + #define DRM_DEBUG_ATOMIC(fmt, args...) \ 231 + drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", fmt, ##args) 232 + 233 + #define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \ 234 + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \ 235 + ##args) 236 + #define DRM_DEBUG_VBL(fmt, args...) \ 237 + drm_printk(KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, ##args) 238 + 239 + #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \ 240 + ({ \ 241 + static DEFINE_RATELIMIT_STATE(_rs, \ 242 + DEFAULT_RATELIMIT_INTERVAL, \ 243 + DEFAULT_RATELIMIT_BURST); \ 244 + if (__ratelimit(&_rs)) \ 245 + drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \ 246 + __func__, "", fmt, ##args); \ 247 + }) 270 248 271 249 /** 272 250 * Rate limited debug output. Like DRM_DEBUG() but won't flood the log. ··· 273 253 * \param fmt printf() like format string. 274 254 * \param arg arguments 275 255 */ 256 + #define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \ 257 + DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args) 276 258 #define DRM_DEBUG_RATELIMITED(fmt, args...) \ 277 - _DRM_DEFINE_DEBUG_RATELIMITED(CORE, fmt, ##args) 259 + DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args) 260 + #define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \ 261 + _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args) 278 262 #define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \ 279 - _DRM_DEFINE_DEBUG_RATELIMITED(DRIVER, fmt, ##args) 263 + DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args) 264 + #define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \ 265 + _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args) 280 266 #define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \ 281 - _DRM_DEFINE_DEBUG_RATELIMITED(KMS, fmt, ##args) 267 + DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args) 268 + #define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \ 269 + _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args) 282 270 #define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \ 283 - _DRM_DEFINE_DEBUG_RATELIMITED(PRIME, fmt, ##args) 271 + DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args) 284 272 285 273 /*@}*/ 286 274
+2
include/drm/drm_atomic_helper.h
··· 29 29 #define DRM_ATOMIC_HELPER_H_ 30 30 31 31 #include <drm/drm_crtc.h> 32 + #include <drm/drm_modeset_helper_vtables.h> 33 + #include <drm/drm_modeset_helper.h> 32 34 33 35 struct drm_atomic_state; 34 36
+747
include/drm/drm_connector.h
··· 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 + #ifndef __DRM_CONNECTOR_H__ 24 + #define __DRM_CONNECTOR_H__ 25 + 26 + #include <linux/list.h> 27 + #include <linux/ctype.h> 28 + #include <drm/drm_modeset.h> 29 + 30 + struct drm_connector_helper_funcs; 31 + struct drm_device; 32 + struct drm_crtc; 33 + struct drm_encoder; 34 + struct drm_property; 35 + struct drm_property_blob; 36 + struct edid; 37 + 38 + enum drm_connector_force { 39 + DRM_FORCE_UNSPECIFIED, 40 + DRM_FORCE_OFF, 41 + DRM_FORCE_ON, /* force on analog part normally */ 42 + DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ 43 + }; 44 + 45 + /** 46 + * enum drm_connector_status - status for a &drm_connector 47 + * 48 + * This enum is used to track the connector status. There are no separate 49 + * #defines for the uapi! 50 + */ 51 + enum drm_connector_status { 52 + /** 53 + * @connector_status_connected: The connector is definitely connected to 54 + * a sink device, and can be enabled. 55 + */ 56 + connector_status_connected = 1, 57 + /** 58 + * @connector_status_disconnected: The connector isn't connected to a 59 + * sink device which can be autodetect. For digital outputs like DP or 60 + * HDMI (which can be realiable probed) this means there's really 61 + * nothing there. It is driver-dependent whether a connector with this 62 + * status can be lit up or not. 63 + */ 64 + connector_status_disconnected = 2, 65 + /** 66 + * @connector_status_unknown: The connector's status could not be 67 + * reliably detected. This happens when probing would either cause 68 + * flicker (like load-detection when the connector is in use), or when a 69 + * hardware resource isn't available (like when load-detection needs a 70 + * free CRTC). It should be possible to light up the connector with one 71 + * of the listed fallback modes. For default configuration userspace 72 + * should only try to light up connectors with unknown status when 73 + * there's not connector with @connector_status_connected. 74 + */ 75 + connector_status_unknown = 3, 76 + }; 77 + 78 + enum subpixel_order { 79 + SubPixelUnknown = 0, 80 + SubPixelHorizontalRGB, 81 + SubPixelHorizontalBGR, 82 + SubPixelVerticalRGB, 83 + SubPixelVerticalBGR, 84 + SubPixelNone, 85 + }; 86 + 87 + /** 88 + * struct drm_display_info - runtime data about the connected sink 89 + * 90 + * Describes a given display (e.g. CRT or flat panel) and its limitations. For 91 + * fixed display sinks like built-in panels there's not much difference between 92 + * this and struct &drm_connector. But for sinks with a real cable this 93 + * structure is meant to describe all the things at the other end of the cable. 94 + * 95 + * For sinks which provide an EDID this can be filled out by calling 96 + * drm_add_edid_modes(). 97 + */ 98 + struct drm_display_info { 99 + /** 100 + * @name: Name of the display. 101 + */ 102 + char name[DRM_DISPLAY_INFO_LEN]; 103 + 104 + /** 105 + * @width_mm: Physical width in mm. 106 + */ 107 + unsigned int width_mm; 108 + /** 109 + * @height_mm: Physical height in mm. 110 + */ 111 + unsigned int height_mm; 112 + 113 + /** 114 + * @pixel_clock: Maximum pixel clock supported by the sink, in units of 115 + * 100Hz. This mismatches the clok in &drm_display_mode (which is in 116 + * kHZ), because that's what the EDID uses as base unit. 117 + */ 118 + unsigned int pixel_clock; 119 + /** 120 + * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs. 121 + */ 122 + unsigned int bpc; 123 + 124 + /** 125 + * @subpixel_order: Subpixel order of LCD panels. 126 + */ 127 + enum subpixel_order subpixel_order; 128 + 129 + #define DRM_COLOR_FORMAT_RGB444 (1<<0) 130 + #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) 131 + #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) 132 + 133 + /** 134 + * @color_formats: HDMI Color formats, selects between RGB and YCrCb 135 + * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones 136 + * as used to describe the pixel format in framebuffers, and also don't 137 + * match the formats in @bus_formats which are shared with v4l. 138 + */ 139 + u32 color_formats; 140 + 141 + /** 142 + * @bus_formats: Pixel data format on the wire, somewhat redundant with 143 + * @color_formats. Array of size @num_bus_formats encoded using 144 + * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers. 145 + */ 146 + const u32 *bus_formats; 147 + /** 148 + * @num_bus_formats: Size of @bus_formats array. 149 + */ 150 + unsigned int num_bus_formats; 151 + 152 + #define DRM_BUS_FLAG_DE_LOW (1<<0) 153 + #define DRM_BUS_FLAG_DE_HIGH (1<<1) 154 + /* drive data on pos. edge */ 155 + #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2) 156 + /* drive data on neg. edge */ 157 + #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3) 158 + 159 + /** 160 + * @bus_flags: Additional information (like pixel signal polarity) for 161 + * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines. 162 + */ 163 + u32 bus_flags; 164 + 165 + /** 166 + * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even 167 + * more stuff redundant with @bus_formats. 168 + */ 169 + u8 edid_hdmi_dc_modes; 170 + 171 + /** 172 + * @cea_rev: CEA revision of the HDMI sink. 173 + */ 174 + u8 cea_rev; 175 + }; 176 + 177 + int drm_display_info_set_bus_formats(struct drm_display_info *info, 178 + const u32 *formats, 179 + unsigned int num_formats); 180 + 181 + /** 182 + * struct drm_connector_state - mutable connector state 183 + * @connector: backpointer to the connector 184 + * @crtc: CRTC to connect connector to, NULL if disabled 185 + * @best_encoder: can be used by helpers and drivers to select the encoder 186 + * @state: backpointer to global drm_atomic_state 187 + */ 188 + struct drm_connector_state { 189 + struct drm_connector *connector; 190 + 191 + struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ 192 + 193 + struct drm_encoder *best_encoder; 194 + 195 + struct drm_atomic_state *state; 196 + }; 197 + 198 + /** 199 + * struct drm_connector_funcs - control connectors on a given device 200 + * 201 + * Each CRTC may have one or more connectors attached to it. The functions 202 + * below allow the core DRM code to control connectors, enumerate available modes, 203 + * etc. 204 + */ 205 + struct drm_connector_funcs { 206 + /** 207 + * @dpms: 208 + * 209 + * Legacy entry point to set the per-connector DPMS state. Legacy DPMS 210 + * is exposed as a standard property on the connector, but diverted to 211 + * this callback in the drm core. Note that atomic drivers don't 212 + * implement the 4 level DPMS support on the connector any more, but 213 + * instead only have an on/off "ACTIVE" property on the CRTC object. 214 + * 215 + * Drivers implementing atomic modeset should use 216 + * drm_atomic_helper_connector_dpms() to implement this hook. 217 + * 218 + * RETURNS: 219 + * 220 + * 0 on success or a negative error code on failure. 221 + */ 222 + int (*dpms)(struct drm_connector *connector, int mode); 223 + 224 + /** 225 + * @reset: 226 + * 227 + * Reset connector hardware and software state to off. This function isn't 228 + * called by the core directly, only through drm_mode_config_reset(). 229 + * It's not a helper hook only for historical reasons. 230 + * 231 + * Atomic drivers can use drm_atomic_helper_connector_reset() to reset 232 + * atomic state using this hook. 233 + */ 234 + void (*reset)(struct drm_connector *connector); 235 + 236 + /** 237 + * @detect: 238 + * 239 + * Check to see if anything is attached to the connector. The parameter 240 + * force is set to false whilst polling, true when checking the 241 + * connector due to a user request. force can be used by the driver to 242 + * avoid expensive, destructive operations during automated probing. 243 + * 244 + * FIXME: 245 + * 246 + * Note that this hook is only called by the probe helper. It's not in 247 + * the helper library vtable purely for historical reasons. The only DRM 248 + * core entry point to probe connector state is @fill_modes. 249 + * 250 + * RETURNS: 251 + * 252 + * drm_connector_status indicating the connector's status. 253 + */ 254 + enum drm_connector_status (*detect)(struct drm_connector *connector, 255 + bool force); 256 + 257 + /** 258 + * @force: 259 + * 260 + * This function is called to update internal encoder state when the 261 + * connector is forced to a certain state by userspace, either through 262 + * the sysfs interfaces or on the kernel cmdline. In that case the 263 + * @detect callback isn't called. 264 + * 265 + * FIXME: 266 + * 267 + * Note that this hook is only called by the probe helper. It's not in 268 + * the helper library vtable purely for historical reasons. The only DRM 269 + * core entry point to probe connector state is @fill_modes. 270 + */ 271 + void (*force)(struct drm_connector *connector); 272 + 273 + /** 274 + * @fill_modes: 275 + * 276 + * Entry point for output detection and basic mode validation. The 277 + * driver should reprobe the output if needed (e.g. when hotplug 278 + * handling is unreliable), add all detected modes to connector->modes 279 + * and filter out any the device can't support in any configuration. It 280 + * also needs to filter out any modes wider or higher than the 281 + * parameters max_width and max_height indicate. 282 + * 283 + * The drivers must also prune any modes no longer valid from 284 + * connector->modes. Furthermore it must update connector->status and 285 + * connector->edid. If no EDID has been received for this output 286 + * connector->edid must be NULL. 287 + * 288 + * Drivers using the probe helpers should use 289 + * drm_helper_probe_single_connector_modes() or 290 + * drm_helper_probe_single_connector_modes_nomerge() to implement this 291 + * function. 292 + * 293 + * RETURNS: 294 + * 295 + * The number of modes detected and filled into connector->modes. 296 + */ 297 + int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); 298 + 299 + /** 300 + * @set_property: 301 + * 302 + * This is the legacy entry point to update a property attached to the 303 + * connector. 304 + * 305 + * Drivers implementing atomic modeset should use 306 + * drm_atomic_helper_connector_set_property() to implement this hook. 307 + * 308 + * This callback is optional if the driver does not support any legacy 309 + * driver-private properties. 310 + * 311 + * RETURNS: 312 + * 313 + * 0 on success or a negative error code on failure. 314 + */ 315 + int (*set_property)(struct drm_connector *connector, struct drm_property *property, 316 + uint64_t val); 317 + 318 + /** 319 + * @late_register: 320 + * 321 + * This optional hook can be used to register additional userspace 322 + * interfaces attached to the connector, light backlight control, i2c, 323 + * DP aux or similar interfaces. It is called late in the driver load 324 + * sequence from drm_connector_register() when registering all the 325 + * core drm connector interfaces. Everything added from this callback 326 + * should be unregistered in the early_unregister callback. 327 + * 328 + * Returns: 329 + * 330 + * 0 on success, or a negative error code on failure. 331 + */ 332 + int (*late_register)(struct drm_connector *connector); 333 + 334 + /** 335 + * @early_unregister: 336 + * 337 + * This optional hook should be used to unregister the additional 338 + * userspace interfaces attached to the connector from 339 + * late_unregister(). It is called from drm_connector_unregister(), 340 + * early in the driver unload sequence to disable userspace access 341 + * before data structures are torndown. 342 + */ 343 + void (*early_unregister)(struct drm_connector *connector); 344 + 345 + /** 346 + * @destroy: 347 + * 348 + * Clean up connector resources. This is called at driver unload time 349 + * through drm_mode_config_cleanup(). It can also be called at runtime 350 + * when a connector is being hot-unplugged for drivers that support 351 + * connector hotplugging (e.g. DisplayPort MST). 352 + */ 353 + void (*destroy)(struct drm_connector *connector); 354 + 355 + /** 356 + * @atomic_duplicate_state: 357 + * 358 + * Duplicate the current atomic state for this connector and return it. 359 + * The core and helpers gurantee that any atomic state duplicated with 360 + * this hook and still owned by the caller (i.e. not transferred to the 361 + * driver by calling ->atomic_commit() from struct 362 + * &drm_mode_config_funcs) will be cleaned up by calling the 363 + * @atomic_destroy_state hook in this structure. 364 + * 365 + * Atomic drivers which don't subclass struct &drm_connector_state should use 366 + * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the 367 + * state structure to extend it with driver-private state should use 368 + * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is 369 + * duplicated in a consistent fashion across drivers. 370 + * 371 + * It is an error to call this hook before connector->state has been 372 + * initialized correctly. 373 + * 374 + * NOTE: 375 + * 376 + * If the duplicate state references refcounted resources this hook must 377 + * acquire a reference for each of them. The driver must release these 378 + * references again in @atomic_destroy_state. 379 + * 380 + * RETURNS: 381 + * 382 + * Duplicated atomic state or NULL when the allocation failed. 383 + */ 384 + struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); 385 + 386 + /** 387 + * @atomic_destroy_state: 388 + * 389 + * Destroy a state duplicated with @atomic_duplicate_state and release 390 + * or unreference all resources it references 391 + */ 392 + void (*atomic_destroy_state)(struct drm_connector *connector, 393 + struct drm_connector_state *state); 394 + 395 + /** 396 + * @atomic_set_property: 397 + * 398 + * Decode a driver-private property value and store the decoded value 399 + * into the passed-in state structure. Since the atomic core decodes all 400 + * standardized properties (even for extensions beyond the core set of 401 + * properties which might not be implemented by all drivers) this 402 + * requires drivers to subclass the state structure. 403 + * 404 + * Such driver-private properties should really only be implemented for 405 + * truly hardware/vendor specific state. Instead it is preferred to 406 + * standardize atomic extension and decode the properties used to expose 407 + * such an extension in the core. 408 + * 409 + * Do not call this function directly, use 410 + * drm_atomic_connector_set_property() instead. 411 + * 412 + * This callback is optional if the driver does not support any 413 + * driver-private atomic properties. 414 + * 415 + * NOTE: 416 + * 417 + * This function is called in the state assembly phase of atomic 418 + * modesets, which can be aborted for any reason (including on 419 + * userspace's request to just check whether a configuration would be 420 + * possible). Drivers MUST NOT touch any persistent state (hardware or 421 + * software) or data structures except the passed in @state parameter. 422 + * 423 + * Also since userspace controls in which order properties are set this 424 + * function must not do any input validation (since the state update is 425 + * incomplete and hence likely inconsistent). Instead any such input 426 + * validation must be done in the various atomic_check callbacks. 427 + * 428 + * RETURNS: 429 + * 430 + * 0 if the property has been found, -EINVAL if the property isn't 431 + * implemented by the driver (which shouldn't ever happen, the core only 432 + * asks for properties attached to this connector). No other validation 433 + * is allowed by the driver. The core already checks that the property 434 + * value is within the range (integer, valid enum value, ...) the driver 435 + * set when registering the property. 436 + */ 437 + int (*atomic_set_property)(struct drm_connector *connector, 438 + struct drm_connector_state *state, 439 + struct drm_property *property, 440 + uint64_t val); 441 + 442 + /** 443 + * @atomic_get_property: 444 + * 445 + * Reads out the decoded driver-private property. This is used to 446 + * implement the GETCONNECTOR IOCTL. 447 + * 448 + * Do not call this function directly, use 449 + * drm_atomic_connector_get_property() instead. 450 + * 451 + * This callback is optional if the driver does not support any 452 + * driver-private atomic properties. 453 + * 454 + * RETURNS: 455 + * 456 + * 0 on success, -EINVAL if the property isn't implemented by the 457 + * driver (which shouldn't ever happen, the core only asks for 458 + * properties attached to this connector). 459 + */ 460 + int (*atomic_get_property)(struct drm_connector *connector, 461 + const struct drm_connector_state *state, 462 + struct drm_property *property, 463 + uint64_t *val); 464 + }; 465 + 466 + /* mode specified on the command line */ 467 + struct drm_cmdline_mode { 468 + bool specified; 469 + bool refresh_specified; 470 + bool bpp_specified; 471 + int xres, yres; 472 + int bpp; 473 + int refresh; 474 + bool rb; 475 + bool interlace; 476 + bool cvt; 477 + bool margins; 478 + enum drm_connector_force force; 479 + }; 480 + 481 + /** 482 + * struct drm_connector - central DRM connector control structure 483 + * @dev: parent DRM device 484 + * @kdev: kernel device for sysfs attributes 485 + * @attr: sysfs attributes 486 + * @head: list management 487 + * @base: base KMS object 488 + * @name: human readable name, can be overwritten by the driver 489 + * @connector_type: one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h 490 + * @connector_type_id: index into connector type enum 491 + * @interlace_allowed: can this connector handle interlaced modes? 492 + * @doublescan_allowed: can this connector handle doublescan? 493 + * @stereo_allowed: can this connector handle stereo modes? 494 + * @registered: is this connector exposed (registered) with userspace? 495 + * @modes: modes available on this connector (from fill_modes() + user) 496 + * @status: one of the drm_connector_status enums (connected, not, or unknown) 497 + * @probed_modes: list of modes derived directly from the display 498 + * @funcs: connector control functions 499 + * @edid_blob_ptr: DRM property containing EDID if present 500 + * @properties: property tracking for this connector 501 + * @dpms: current dpms state 502 + * @helper_private: mid-layer private data 503 + * @cmdline_mode: mode line parsed from the kernel cmdline for this connector 504 + * @force: a DRM_FORCE_<foo> state for forced mode sets 505 + * @override_edid: has the EDID been overwritten through debugfs for testing? 506 + * @encoder_ids: valid encoders for this connector 507 + * @encoder: encoder driving this connector, if any 508 + * @eld: EDID-like data, if present 509 + * @dvi_dual: dual link DVI, if found 510 + * @max_tmds_clock: max clock rate, if found 511 + * @latency_present: AV delay info from ELD, if found 512 + * @video_latency: video latency info from ELD, if found 513 + * @audio_latency: audio latency info from ELD, if found 514 + * @null_edid_counter: track sinks that give us all zeros for the EDID 515 + * @bad_edid_counter: track sinks that give us an EDID with invalid checksum 516 + * @edid_corrupt: indicates whether the last read EDID was corrupt 517 + * @debugfs_entry: debugfs directory for this connector 518 + * @state: current atomic state for this connector 519 + * @has_tile: is this connector connected to a tiled monitor 520 + * @tile_group: tile group for the connected monitor 521 + * @tile_is_single_monitor: whether the tile is one monitor housing 522 + * @num_h_tile: number of horizontal tiles in the tile group 523 + * @num_v_tile: number of vertical tiles in the tile group 524 + * @tile_h_loc: horizontal location of this tile 525 + * @tile_v_loc: vertical location of this tile 526 + * @tile_h_size: horizontal size of this tile. 527 + * @tile_v_size: vertical size of this tile. 528 + * 529 + * Each connector may be connected to one or more CRTCs, or may be clonable by 530 + * another connector if they can share a CRTC. Each connector also has a specific 531 + * position in the broader display (referred to as a 'screen' though it could 532 + * span multiple monitors). 533 + */ 534 + struct drm_connector { 535 + struct drm_device *dev; 536 + struct device *kdev; 537 + struct device_attribute *attr; 538 + struct list_head head; 539 + 540 + struct drm_mode_object base; 541 + 542 + char *name; 543 + 544 + /** 545 + * @index: Compacted connector index, which matches the position inside 546 + * the mode_config.list for drivers not supporting hot-add/removing. Can 547 + * be used as an array index. It is invariant over the lifetime of the 548 + * connector. 549 + */ 550 + unsigned index; 551 + 552 + int connector_type; 553 + int connector_type_id; 554 + bool interlace_allowed; 555 + bool doublescan_allowed; 556 + bool stereo_allowed; 557 + bool registered; 558 + struct list_head modes; /* list of modes on this connector */ 559 + 560 + enum drm_connector_status status; 561 + 562 + /* these are modes added by probing with DDC or the BIOS */ 563 + struct list_head probed_modes; 564 + 565 + /** 566 + * @display_info: Display information is filled from EDID information 567 + * when a display is detected. For non hot-pluggable displays such as 568 + * flat panels in embedded systems, the driver should initialize the 569 + * display_info.width_mm and display_info.height_mm fields with the 570 + * physical size of the display. 571 + */ 572 + struct drm_display_info display_info; 573 + const struct drm_connector_funcs *funcs; 574 + 575 + struct drm_property_blob *edid_blob_ptr; 576 + struct drm_object_properties properties; 577 + 578 + /** 579 + * @path_blob_ptr: 580 + * 581 + * DRM blob property data for the DP MST path property. 582 + */ 583 + struct drm_property_blob *path_blob_ptr; 584 + 585 + /** 586 + * @tile_blob_ptr: 587 + * 588 + * DRM blob property data for the tile property (used mostly by DP MST). 589 + * This is meant for screens which are driven through separate display 590 + * pipelines represented by &drm_crtc, which might not be running with 591 + * genlocked clocks. For tiled panels which are genlocked, like 592 + * dual-link LVDS or dual-link DSI, the driver should try to not expose 593 + * the tiling and virtualize both &drm_crtc and &drm_plane if needed. 594 + */ 595 + struct drm_property_blob *tile_blob_ptr; 596 + 597 + /* should we poll this connector for connects and disconnects */ 598 + /* hot plug detectable */ 599 + #define DRM_CONNECTOR_POLL_HPD (1 << 0) 600 + /* poll for connections */ 601 + #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) 602 + /* can cleanly poll for disconnections without flickering the screen */ 603 + /* DACs should rarely do this without a lot of testing */ 604 + #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) 605 + 606 + /** 607 + * @polled: 608 + * 609 + * Connector polling mode, a combination of 610 + * 611 + * DRM_CONNECTOR_POLL_HPD 612 + * The connector generates hotplug events and doesn't need to be 613 + * periodically polled. The CONNECT and DISCONNECT flags must not 614 + * be set together with the HPD flag. 615 + * 616 + * DRM_CONNECTOR_POLL_CONNECT 617 + * Periodically poll the connector for connection. 618 + * 619 + * DRM_CONNECTOR_POLL_DISCONNECT 620 + * Periodically poll the connector for disconnection. 621 + * 622 + * Set to 0 for connectors that don't support connection status 623 + * discovery. 624 + */ 625 + uint8_t polled; 626 + 627 + /* requested DPMS state */ 628 + int dpms; 629 + 630 + const struct drm_connector_helper_funcs *helper_private; 631 + 632 + /* forced on connector */ 633 + struct drm_cmdline_mode cmdline_mode; 634 + enum drm_connector_force force; 635 + bool override_edid; 636 + 637 + #define DRM_CONNECTOR_MAX_ENCODER 3 638 + uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; 639 + struct drm_encoder *encoder; /* currently active encoder */ 640 + 641 + #define MAX_ELD_BYTES 128 642 + /* EDID bits */ 643 + uint8_t eld[MAX_ELD_BYTES]; 644 + bool dvi_dual; 645 + int max_tmds_clock; /* in MHz */ 646 + bool latency_present[2]; 647 + int video_latency[2]; /* [0]: progressive, [1]: interlaced */ 648 + int audio_latency[2]; 649 + int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ 650 + unsigned bad_edid_counter; 651 + 652 + /* Flag for raw EDID header corruption - used in Displayport 653 + * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6 654 + */ 655 + bool edid_corrupt; 656 + 657 + struct dentry *debugfs_entry; 658 + 659 + struct drm_connector_state *state; 660 + 661 + /* DisplayID bits */ 662 + bool has_tile; 663 + struct drm_tile_group *tile_group; 664 + bool tile_is_single_monitor; 665 + 666 + uint8_t num_h_tile, num_v_tile; 667 + uint8_t tile_h_loc, tile_v_loc; 668 + uint16_t tile_h_size, tile_v_size; 669 + }; 670 + 671 + #define obj_to_connector(x) container_of(x, struct drm_connector, base) 672 + 673 + int drm_connector_init(struct drm_device *dev, 674 + struct drm_connector *connector, 675 + const struct drm_connector_funcs *funcs, 676 + int connector_type); 677 + int drm_connector_register(struct drm_connector *connector); 678 + void drm_connector_unregister(struct drm_connector *connector); 679 + int drm_mode_connector_attach_encoder(struct drm_connector *connector, 680 + struct drm_encoder *encoder); 681 + 682 + void drm_connector_cleanup(struct drm_connector *connector); 683 + static inline unsigned drm_connector_index(struct drm_connector *connector) 684 + { 685 + return connector->index; 686 + } 687 + 688 + /** 689 + * drm_connector_lookup - lookup connector object 690 + * @dev: DRM device 691 + * @id: connector object id 692 + * 693 + * This function looks up the connector object specified by id 694 + * add takes a reference to it. 695 + */ 696 + static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev, 697 + uint32_t id) 698 + { 699 + struct drm_mode_object *mo; 700 + mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR); 701 + return mo ? obj_to_connector(mo) : NULL; 702 + } 703 + 704 + /** 705 + * drm_connector_reference - incr the connector refcnt 706 + * @connector: connector 707 + * 708 + * This function increments the connector's refcount. 709 + */ 710 + static inline void drm_connector_reference(struct drm_connector *connector) 711 + { 712 + drm_mode_object_reference(&connector->base); 713 + } 714 + 715 + /** 716 + * drm_connector_unreference - unref a connector 717 + * @connector: connector to unref 718 + * 719 + * This function decrements the connector's refcount and frees it if it drops to zero. 720 + */ 721 + static inline void drm_connector_unreference(struct drm_connector *connector) 722 + { 723 + drm_mode_object_unreference(&connector->base); 724 + } 725 + 726 + const char *drm_get_connector_status_name(enum drm_connector_status status); 727 + const char *drm_get_subpixel_order_name(enum subpixel_order order); 728 + const char *drm_get_dpms_name(int val); 729 + const char *drm_get_dvi_i_subconnector_name(int val); 730 + const char *drm_get_dvi_i_select_name(int val); 731 + const char *drm_get_tv_subconnector_name(int val); 732 + const char *drm_get_tv_select_name(int val); 733 + 734 + int drm_mode_create_dvi_i_properties(struct drm_device *dev); 735 + int drm_mode_create_tv_properties(struct drm_device *dev, 736 + unsigned int num_modes, 737 + const char * const modes[]); 738 + int drm_mode_create_scaling_mode_property(struct drm_device *dev); 739 + int drm_mode_create_aspect_ratio_property(struct drm_device *dev); 740 + int drm_mode_create_suggested_offset_properties(struct drm_device *dev); 741 + 742 + int drm_mode_connector_set_path_property(struct drm_connector *connector, 743 + const char *path); 744 + int drm_mode_connector_set_tile_property(struct drm_connector *connector); 745 + int drm_mode_connector_update_edid_property(struct drm_connector *connector, 746 + const struct edid *edid); 747 + #endif
+11 -781
include/drm/drm_crtc.h
··· 36 36 #include <uapi/drm/drm_fourcc.h> 37 37 #include <drm/drm_modeset_lock.h> 38 38 #include <drm/drm_rect.h> 39 + #include <drm/drm_modeset.h> 40 + #include <drm/drm_framebuffer.h> 41 + #include <drm/drm_modes.h> 42 + #include <drm/drm_connector.h> 39 43 40 44 struct drm_device; 41 45 struct drm_mode_set; 42 - struct drm_framebuffer; 43 - struct drm_object_properties; 44 46 struct drm_file; 45 47 struct drm_clip_rect; 46 48 struct device_node; 47 49 struct fence; 48 50 struct edid; 49 - 50 - struct drm_mode_object { 51 - uint32_t id; 52 - uint32_t type; 53 - struct drm_object_properties *properties; 54 - struct kref refcount; 55 - void (*free_cb)(struct kref *kref); 56 - }; 57 - 58 - #define DRM_OBJECT_MAX_PROPERTY 24 59 - struct drm_object_properties { 60 - int count, atomic_count; 61 - /* NOTE: if we ever start dynamically destroying properties (ie. 62 - * not at drm_mode_config_cleanup() time), then we'd have to do 63 - * a better job of detaching property from mode objects to avoid 64 - * dangling property pointers: 65 - */ 66 - struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY]; 67 - /* do not read/write values directly, but use drm_object_property_get_value() 68 - * and drm_object_property_set_value(): 69 - */ 70 - uint64_t values[DRM_OBJECT_MAX_PROPERTY]; 71 - }; 72 51 73 52 static inline int64_t U642I64(uint64_t val) 74 53 { ··· 73 94 #define DRM_REFLECT_Y BIT(5) 74 95 #define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y) 75 96 76 - enum drm_connector_force { 77 - DRM_FORCE_UNSPECIFIED, 78 - DRM_FORCE_OFF, 79 - DRM_FORCE_ON, /* force on analog part normally */ 80 - DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ 81 - }; 82 - 83 - #include <drm/drm_modes.h> 84 - 85 - enum drm_connector_status { 86 - connector_status_connected = 1, 87 - connector_status_disconnected = 2, 88 - connector_status_unknown = 3, 89 - }; 90 - 91 - enum subpixel_order { 92 - SubPixelUnknown = 0, 93 - SubPixelHorizontalRGB, 94 - SubPixelHorizontalBGR, 95 - SubPixelVerticalRGB, 96 - SubPixelVerticalBGR, 97 - SubPixelNone, 98 - }; 99 - 100 - #define DRM_COLOR_FORMAT_RGB444 (1<<0) 101 - #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) 102 - #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) 103 - 104 - #define DRM_BUS_FLAG_DE_LOW (1<<0) 105 - #define DRM_BUS_FLAG_DE_HIGH (1<<1) 106 - /* drive data on pos. edge */ 107 - #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2) 108 - /* drive data on neg. edge */ 109 - #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3) 110 - 111 - /* 112 - * Describes a given display (e.g. CRT or flat panel) and its limitations. 113 - */ 114 - struct drm_display_info { 115 - char name[DRM_DISPLAY_INFO_LEN]; 116 - 117 - /* Physical size */ 118 - unsigned int width_mm; 119 - unsigned int height_mm; 120 - 121 - /* Clock limits FIXME: storage format */ 122 - unsigned int min_vfreq, max_vfreq; 123 - unsigned int min_hfreq, max_hfreq; 124 - unsigned int pixel_clock; 125 - unsigned int bpc; 126 - 127 - enum subpixel_order subpixel_order; 128 - u32 color_formats; 129 - 130 - const u32 *bus_formats; 131 - unsigned int num_bus_formats; 132 - u32 bus_flags; 133 - 134 - /* Mask of supported hdmi deep color modes */ 135 - u8 edid_hdmi_dc_modes; 136 - 137 - u8 cea_rev; 138 - }; 139 - 140 97 /* data corresponds to displayid vend/prod/serial */ 141 98 struct drm_tile_group { 142 99 struct kref refcount; 143 100 struct drm_device *dev; 144 101 int id; 145 102 u8 group_data[8]; 146 - }; 147 - 148 - /** 149 - * struct drm_framebuffer_funcs - framebuffer hooks 150 - */ 151 - struct drm_framebuffer_funcs { 152 - /** 153 - * @destroy: 154 - * 155 - * Clean up framebuffer resources, specifically also unreference the 156 - * backing storage. The core guarantees to call this function for every 157 - * framebuffer successfully created by ->fb_create() in 158 - * &drm_mode_config_funcs. Drivers must also call 159 - * drm_framebuffer_cleanup() to release DRM core resources for this 160 - * framebuffer. 161 - */ 162 - void (*destroy)(struct drm_framebuffer *framebuffer); 163 - 164 - /** 165 - * @create_handle: 166 - * 167 - * Create a buffer handle in the driver-specific buffer manager (either 168 - * GEM or TTM) valid for the passed-in struct &drm_file. This is used by 169 - * the core to implement the GETFB IOCTL, which returns (for 170 - * sufficiently priviledged user) also a native buffer handle. This can 171 - * be used for seamless transitions between modesetting clients by 172 - * copying the current screen contents to a private buffer and blending 173 - * between that and the new contents. 174 - * 175 - * GEM based drivers should call drm_gem_handle_create() to create the 176 - * handle. 177 - * 178 - * RETURNS: 179 - * 180 - * 0 on success or a negative error code on failure. 181 - */ 182 - int (*create_handle)(struct drm_framebuffer *fb, 183 - struct drm_file *file_priv, 184 - unsigned int *handle); 185 - /** 186 - * @dirty: 187 - * 188 - * Optional callback for the dirty fb IOCTL. 189 - * 190 - * Userspace can notify the driver via this callback that an area of the 191 - * framebuffer has changed and should be flushed to the display 192 - * hardware. This can also be used internally, e.g. by the fbdev 193 - * emulation, though that's not the case currently. 194 - * 195 - * See documentation in drm_mode.h for the struct drm_mode_fb_dirty_cmd 196 - * for more information as all the semantics and arguments have a one to 197 - * one mapping on this function. 198 - * 199 - * RETURNS: 200 - * 201 - * 0 on success or a negative error code on failure. 202 - */ 203 - int (*dirty)(struct drm_framebuffer *framebuffer, 204 - struct drm_file *file_priv, unsigned flags, 205 - unsigned color, struct drm_clip_rect *clips, 206 - unsigned num_clips); 207 - }; 208 - 209 - struct drm_framebuffer { 210 - struct drm_device *dev; 211 - /* 212 - * Note that the fb is refcounted for the benefit of driver internals, 213 - * for example some hw, disabling a CRTC/plane is asynchronous, and 214 - * scanout does not actually complete until the next vblank. So some 215 - * cleanup (like releasing the reference(s) on the backing GEM bo(s)) 216 - * should be deferred. In cases like this, the driver would like to 217 - * hold a ref to the fb even though it has already been removed from 218 - * userspace perspective. 219 - * The refcount is stored inside the mode object. 220 - */ 221 - /* 222 - * Place on the dev->mode_config.fb_list, access protected by 223 - * dev->mode_config.fb_lock. 224 - */ 225 - struct list_head head; 226 - struct drm_mode_object base; 227 - const struct drm_framebuffer_funcs *funcs; 228 - unsigned int pitches[4]; 229 - unsigned int offsets[4]; 230 - uint64_t modifier[4]; 231 - unsigned int width; 232 - unsigned int height; 233 - /* depth can be 15 or 16 */ 234 - unsigned int depth; 235 - int bits_per_pixel; 236 - int flags; 237 - uint32_t pixel_format; /* fourcc format */ 238 - int hot_x; 239 - int hot_y; 240 - struct list_head filp_head; 241 103 }; 242 104 243 105 struct drm_property_blob { ··· 109 289 }; 110 290 111 291 struct drm_crtc; 112 - struct drm_connector; 113 292 struct drm_encoder; 114 293 struct drm_pending_vblank_event; 115 294 struct drm_plane; ··· 117 298 118 299 struct drm_crtc_helper_funcs; 119 300 struct drm_encoder_helper_funcs; 120 - struct drm_connector_helper_funcs; 121 301 struct drm_plane_helper_funcs; 122 302 123 303 /** ··· 364 546 * drm_crtc_vblank_put(). Drivers are free to implement their own vblank 365 547 * counter and timestamp tracking though, e.g. if they have accurate 366 548 * timestamp registers in hardware. 367 - * 368 - * FIXME: 369 - * 370 - * Up to that point drivers need to manage events themselves and can use 371 - * even->base.list freely for that. Specifically they need to ensure 372 - * that they don't send out page flip (or vblank) events for which the 373 - * corresponding drm file has been closed already. The drm core 374 - * unfortunately does not (yet) take care of that. Therefore drivers 375 - * currently must clean up and release pending events in their 376 - * ->preclose driver function. 377 549 * 378 550 * This callback is optional. 379 551 * ··· 662 854 }; 663 855 664 856 /** 665 - * struct drm_connector_state - mutable connector state 666 - * @connector: backpointer to the connector 667 - * @crtc: CRTC to connect connector to, NULL if disabled 668 - * @best_encoder: can be used by helpers and drivers to select the encoder 669 - * @state: backpointer to global drm_atomic_state 670 - */ 671 - struct drm_connector_state { 672 - struct drm_connector *connector; 673 - 674 - struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ 675 - 676 - struct drm_encoder *best_encoder; 677 - 678 - struct drm_atomic_state *state; 679 - }; 680 - 681 - /** 682 - * struct drm_connector_funcs - control connectors on a given device 683 - * 684 - * Each CRTC may have one or more connectors attached to it. The functions 685 - * below allow the core DRM code to control connectors, enumerate available modes, 686 - * etc. 687 - */ 688 - struct drm_connector_funcs { 689 - /** 690 - * @dpms: 691 - * 692 - * Legacy entry point to set the per-connector DPMS state. Legacy DPMS 693 - * is exposed as a standard property on the connector, but diverted to 694 - * this callback in the drm core. Note that atomic drivers don't 695 - * implement the 4 level DPMS support on the connector any more, but 696 - * instead only have an on/off "ACTIVE" property on the CRTC object. 697 - * 698 - * Drivers implementing atomic modeset should use 699 - * drm_atomic_helper_connector_dpms() to implement this hook. 700 - * 701 - * RETURNS: 702 - * 703 - * 0 on success or a negative error code on failure. 704 - */ 705 - int (*dpms)(struct drm_connector *connector, int mode); 706 - 707 - /** 708 - * @reset: 709 - * 710 - * Reset connector hardware and software state to off. This function isn't 711 - * called by the core directly, only through drm_mode_config_reset(). 712 - * It's not a helper hook only for historical reasons. 713 - * 714 - * Atomic drivers can use drm_atomic_helper_connector_reset() to reset 715 - * atomic state using this hook. 716 - */ 717 - void (*reset)(struct drm_connector *connector); 718 - 719 - /** 720 - * @detect: 721 - * 722 - * Check to see if anything is attached to the connector. The parameter 723 - * force is set to false whilst polling, true when checking the 724 - * connector due to a user request. force can be used by the driver to 725 - * avoid expensive, destructive operations during automated probing. 726 - * 727 - * FIXME: 728 - * 729 - * Note that this hook is only called by the probe helper. It's not in 730 - * the helper library vtable purely for historical reasons. The only DRM 731 - * core entry point to probe connector state is @fill_modes. 732 - * 733 - * RETURNS: 734 - * 735 - * drm_connector_status indicating the connector's status. 736 - */ 737 - enum drm_connector_status (*detect)(struct drm_connector *connector, 738 - bool force); 739 - 740 - /** 741 - * @force: 742 - * 743 - * This function is called to update internal encoder state when the 744 - * connector is forced to a certain state by userspace, either through 745 - * the sysfs interfaces or on the kernel cmdline. In that case the 746 - * @detect callback isn't called. 747 - * 748 - * FIXME: 749 - * 750 - * Note that this hook is only called by the probe helper. It's not in 751 - * the helper library vtable purely for historical reasons. The only DRM 752 - * core entry point to probe connector state is @fill_modes. 753 - */ 754 - void (*force)(struct drm_connector *connector); 755 - 756 - /** 757 - * @fill_modes: 758 - * 759 - * Entry point for output detection and basic mode validation. The 760 - * driver should reprobe the output if needed (e.g. when hotplug 761 - * handling is unreliable), add all detected modes to connector->modes 762 - * and filter out any the device can't support in any configuration. It 763 - * also needs to filter out any modes wider or higher than the 764 - * parameters max_width and max_height indicate. 765 - * 766 - * The drivers must also prune any modes no longer valid from 767 - * connector->modes. Furthermore it must update connector->status and 768 - * connector->edid. If no EDID has been received for this output 769 - * connector->edid must be NULL. 770 - * 771 - * Drivers using the probe helpers should use 772 - * drm_helper_probe_single_connector_modes() or 773 - * drm_helper_probe_single_connector_modes_nomerge() to implement this 774 - * function. 775 - * 776 - * RETURNS: 777 - * 778 - * The number of modes detected and filled into connector->modes. 779 - */ 780 - int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); 781 - 782 - /** 783 - * @set_property: 784 - * 785 - * This is the legacy entry point to update a property attached to the 786 - * connector. 787 - * 788 - * Drivers implementing atomic modeset should use 789 - * drm_atomic_helper_connector_set_property() to implement this hook. 790 - * 791 - * This callback is optional if the driver does not support any legacy 792 - * driver-private properties. 793 - * 794 - * RETURNS: 795 - * 796 - * 0 on success or a negative error code on failure. 797 - */ 798 - int (*set_property)(struct drm_connector *connector, struct drm_property *property, 799 - uint64_t val); 800 - 801 - /** 802 - * @late_register: 803 - * 804 - * This optional hook can be used to register additional userspace 805 - * interfaces attached to the connector, light backlight control, i2c, 806 - * DP aux or similar interfaces. It is called late in the driver load 807 - * sequence from drm_connector_register() when registering all the 808 - * core drm connector interfaces. Everything added from this callback 809 - * should be unregistered in the early_unregister callback. 810 - * 811 - * Returns: 812 - * 813 - * 0 on success, or a negative error code on failure. 814 - */ 815 - int (*late_register)(struct drm_connector *connector); 816 - 817 - /** 818 - * @early_unregister: 819 - * 820 - * This optional hook should be used to unregister the additional 821 - * userspace interfaces attached to the connector from 822 - * late_unregister(). It is called from drm_connector_unregister(), 823 - * early in the driver unload sequence to disable userspace access 824 - * before data structures are torndown. 825 - */ 826 - void (*early_unregister)(struct drm_connector *connector); 827 - 828 - /** 829 - * @destroy: 830 - * 831 - * Clean up connector resources. This is called at driver unload time 832 - * through drm_mode_config_cleanup(). It can also be called at runtime 833 - * when a connector is being hot-unplugged for drivers that support 834 - * connector hotplugging (e.g. DisplayPort MST). 835 - */ 836 - void (*destroy)(struct drm_connector *connector); 837 - 838 - /** 839 - * @atomic_duplicate_state: 840 - * 841 - * Duplicate the current atomic state for this connector and return it. 842 - * The core and helpers gurantee that any atomic state duplicated with 843 - * this hook and still owned by the caller (i.e. not transferred to the 844 - * driver by calling ->atomic_commit() from struct 845 - * &drm_mode_config_funcs) will be cleaned up by calling the 846 - * @atomic_destroy_state hook in this structure. 847 - * 848 - * Atomic drivers which don't subclass struct &drm_connector_state should use 849 - * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the 850 - * state structure to extend it with driver-private state should use 851 - * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is 852 - * duplicated in a consistent fashion across drivers. 853 - * 854 - * It is an error to call this hook before connector->state has been 855 - * initialized correctly. 856 - * 857 - * NOTE: 858 - * 859 - * If the duplicate state references refcounted resources this hook must 860 - * acquire a reference for each of them. The driver must release these 861 - * references again in @atomic_destroy_state. 862 - * 863 - * RETURNS: 864 - * 865 - * Duplicated atomic state or NULL when the allocation failed. 866 - */ 867 - struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); 868 - 869 - /** 870 - * @atomic_destroy_state: 871 - * 872 - * Destroy a state duplicated with @atomic_duplicate_state and release 873 - * or unreference all resources it references 874 - */ 875 - void (*atomic_destroy_state)(struct drm_connector *connector, 876 - struct drm_connector_state *state); 877 - 878 - /** 879 - * @atomic_set_property: 880 - * 881 - * Decode a driver-private property value and store the decoded value 882 - * into the passed-in state structure. Since the atomic core decodes all 883 - * standardized properties (even for extensions beyond the core set of 884 - * properties which might not be implemented by all drivers) this 885 - * requires drivers to subclass the state structure. 886 - * 887 - * Such driver-private properties should really only be implemented for 888 - * truly hardware/vendor specific state. Instead it is preferred to 889 - * standardize atomic extension and decode the properties used to expose 890 - * such an extension in the core. 891 - * 892 - * Do not call this function directly, use 893 - * drm_atomic_connector_set_property() instead. 894 - * 895 - * This callback is optional if the driver does not support any 896 - * driver-private atomic properties. 897 - * 898 - * NOTE: 899 - * 900 - * This function is called in the state assembly phase of atomic 901 - * modesets, which can be aborted for any reason (including on 902 - * userspace's request to just check whether a configuration would be 903 - * possible). Drivers MUST NOT touch any persistent state (hardware or 904 - * software) or data structures except the passed in @state parameter. 905 - * 906 - * Also since userspace controls in which order properties are set this 907 - * function must not do any input validation (since the state update is 908 - * incomplete and hence likely inconsistent). Instead any such input 909 - * validation must be done in the various atomic_check callbacks. 910 - * 911 - * RETURNS: 912 - * 913 - * 0 if the property has been found, -EINVAL if the property isn't 914 - * implemented by the driver (which shouldn't ever happen, the core only 915 - * asks for properties attached to this connector). No other validation 916 - * is allowed by the driver. The core already checks that the property 917 - * value is within the range (integer, valid enum value, ...) the driver 918 - * set when registering the property. 919 - */ 920 - int (*atomic_set_property)(struct drm_connector *connector, 921 - struct drm_connector_state *state, 922 - struct drm_property *property, 923 - uint64_t val); 924 - 925 - /** 926 - * @atomic_get_property: 927 - * 928 - * Reads out the decoded driver-private property. This is used to 929 - * implement the GETCONNECTOR IOCTL. 930 - * 931 - * Do not call this function directly, use 932 - * drm_atomic_connector_get_property() instead. 933 - * 934 - * This callback is optional if the driver does not support any 935 - * driver-private atomic properties. 936 - * 937 - * RETURNS: 938 - * 939 - * 0 on success, -EINVAL if the property isn't implemented by the 940 - * driver (which shouldn't ever happen, the core only asks for 941 - * properties attached to this connector). 942 - */ 943 - int (*atomic_get_property)(struct drm_connector *connector, 944 - const struct drm_connector_state *state, 945 - struct drm_property *property, 946 - uint64_t *val); 947 - }; 948 - 949 - /** 950 857 * struct drm_encoder_funcs - encoder controls 951 858 * 952 859 * Encoders sit between CRTCs and connectors. ··· 712 1189 void (*early_unregister)(struct drm_encoder *encoder); 713 1190 }; 714 1191 715 - #define DRM_CONNECTOR_MAX_ENCODER 3 716 - 717 1192 /** 718 1193 * struct drm_encoder - central DRM encoder structure 719 1194 * @dev: parent DRM device 720 1195 * @head: list management 721 1196 * @base: base KMS object 722 1197 * @name: human readable name, can be overwritten by the driver 723 - * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h 1198 + * @encoder_type: one of the DRM_MODE_ENCODER_<foo> types in drm_mode.h 724 1199 * @possible_crtcs: bitmask of potential CRTC bindings 725 1200 * @possible_clones: bitmask of potential sibling encoders for cloning 726 1201 * @crtc: currently bound CRTC ··· 750 1229 struct drm_bridge *bridge; 751 1230 const struct drm_encoder_funcs *funcs; 752 1231 const struct drm_encoder_helper_funcs *helper_private; 753 - }; 754 - 755 - /* should we poll this connector for connects and disconnects */ 756 - /* hot plug detectable */ 757 - #define DRM_CONNECTOR_POLL_HPD (1 << 0) 758 - /* poll for connections */ 759 - #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) 760 - /* can cleanly poll for disconnections without flickering the screen */ 761 - /* DACs should rarely do this without a lot of testing */ 762 - #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) 763 - 764 - #define MAX_ELD_BYTES 128 765 - 766 - /** 767 - * struct drm_connector - central DRM connector control structure 768 - * @dev: parent DRM device 769 - * @kdev: kernel device for sysfs attributes 770 - * @attr: sysfs attributes 771 - * @head: list management 772 - * @base: base KMS object 773 - * @name: human readable name, can be overwritten by the driver 774 - * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h 775 - * @connector_type_id: index into connector type enum 776 - * @interlace_allowed: can this connector handle interlaced modes? 777 - * @doublescan_allowed: can this connector handle doublescan? 778 - * @stereo_allowed: can this connector handle stereo modes? 779 - * @registered: is this connector exposed (registered) with userspace? 780 - * @modes: modes available on this connector (from fill_modes() + user) 781 - * @status: one of the drm_connector_status enums (connected, not, or unknown) 782 - * @probed_modes: list of modes derived directly from the display 783 - * @display_info: information about attached display (e.g. from EDID) 784 - * @funcs: connector control functions 785 - * @edid_blob_ptr: DRM property containing EDID if present 786 - * @properties: property tracking for this connector 787 - * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling 788 - * @dpms: current dpms state 789 - * @helper_private: mid-layer private data 790 - * @cmdline_mode: mode line parsed from the kernel cmdline for this connector 791 - * @force: a %DRM_FORCE_<foo> state for forced mode sets 792 - * @override_edid: has the EDID been overwritten through debugfs for testing? 793 - * @encoder_ids: valid encoders for this connector 794 - * @encoder: encoder driving this connector, if any 795 - * @eld: EDID-like data, if present 796 - * @dvi_dual: dual link DVI, if found 797 - * @max_tmds_clock: max clock rate, if found 798 - * @latency_present: AV delay info from ELD, if found 799 - * @video_latency: video latency info from ELD, if found 800 - * @audio_latency: audio latency info from ELD, if found 801 - * @null_edid_counter: track sinks that give us all zeros for the EDID 802 - * @bad_edid_counter: track sinks that give us an EDID with invalid checksum 803 - * @edid_corrupt: indicates whether the last read EDID was corrupt 804 - * @debugfs_entry: debugfs directory for this connector 805 - * @state: current atomic state for this connector 806 - * @has_tile: is this connector connected to a tiled monitor 807 - * @tile_group: tile group for the connected monitor 808 - * @tile_is_single_monitor: whether the tile is one monitor housing 809 - * @num_h_tile: number of horizontal tiles in the tile group 810 - * @num_v_tile: number of vertical tiles in the tile group 811 - * @tile_h_loc: horizontal location of this tile 812 - * @tile_v_loc: vertical location of this tile 813 - * @tile_h_size: horizontal size of this tile. 814 - * @tile_v_size: vertical size of this tile. 815 - * 816 - * Each connector may be connected to one or more CRTCs, or may be clonable by 817 - * another connector if they can share a CRTC. Each connector also has a specific 818 - * position in the broader display (referred to as a 'screen' though it could 819 - * span multiple monitors). 820 - */ 821 - struct drm_connector { 822 - struct drm_device *dev; 823 - struct device *kdev; 824 - struct device_attribute *attr; 825 - struct list_head head; 826 - 827 - struct drm_mode_object base; 828 - 829 - char *name; 830 - 831 - /** 832 - * @index: Compacted connector index, which matches the position inside 833 - * the mode_config.list for drivers not supporting hot-add/removing. Can 834 - * be used as an array index. It is invariant over the lifetime of the 835 - * connector. 836 - */ 837 - unsigned index; 838 - 839 - int connector_type; 840 - int connector_type_id; 841 - bool interlace_allowed; 842 - bool doublescan_allowed; 843 - bool stereo_allowed; 844 - bool registered; 845 - struct list_head modes; /* list of modes on this connector */ 846 - 847 - enum drm_connector_status status; 848 - 849 - /* these are modes added by probing with DDC or the BIOS */ 850 - struct list_head probed_modes; 851 - 852 - struct drm_display_info display_info; 853 - const struct drm_connector_funcs *funcs; 854 - 855 - struct drm_property_blob *edid_blob_ptr; 856 - struct drm_object_properties properties; 857 - 858 - /** 859 - * @path_blob_ptr: 860 - * 861 - * DRM blob property data for the DP MST path property. 862 - */ 863 - struct drm_property_blob *path_blob_ptr; 864 - 865 - /** 866 - * @tile_blob_ptr: 867 - * 868 - * DRM blob property data for the tile property (used mostly by DP MST). 869 - * This is meant for screens which are driven through separate display 870 - * pipelines represented by &drm_crtc, which might not be running with 871 - * genlocked clocks. For tiled panels which are genlocked, like 872 - * dual-link LVDS or dual-link DSI, the driver should try to not expose 873 - * the tiling and virtualize both &drm_crtc and &drm_plane if needed. 874 - */ 875 - struct drm_property_blob *tile_blob_ptr; 876 - 877 - uint8_t polled; /* DRM_CONNECTOR_POLL_* */ 878 - 879 - /* requested DPMS state */ 880 - int dpms; 881 - 882 - const struct drm_connector_helper_funcs *helper_private; 883 - 884 - /* forced on connector */ 885 - struct drm_cmdline_mode cmdline_mode; 886 - enum drm_connector_force force; 887 - bool override_edid; 888 - uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; 889 - struct drm_encoder *encoder; /* currently active encoder */ 890 - 891 - /* EDID bits */ 892 - uint8_t eld[MAX_ELD_BYTES]; 893 - bool dvi_dual; 894 - int max_tmds_clock; /* in MHz */ 895 - bool latency_present[2]; 896 - int video_latency[2]; /* [0]: progressive, [1]: interlaced */ 897 - int audio_latency[2]; 898 - int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ 899 - unsigned bad_edid_counter; 900 - 901 - /* Flag for raw EDID header corruption - used in Displayport 902 - * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6 903 - */ 904 - bool edid_corrupt; 905 - 906 - struct dentry *debugfs_entry; 907 - 908 - struct drm_connector_state *state; 909 - 910 - /* DisplayID bits */ 911 - bool has_tile; 912 - struct drm_tile_group *tile_group; 913 - bool tile_is_single_monitor; 914 - 915 - uint8_t num_h_tile, num_v_tile; 916 - uint8_t tile_h_loc, tile_v_loc; 917 - uint16_t tile_h_size, tile_v_size; 918 1232 }; 919 1233 920 1234 /** ··· 2006 2650 */ 2007 2651 struct drm_property *aspect_ratio_property; 2008 2652 /** 2009 - * @dirty_info_property: Optional connector property to give userspace a 2010 - * hint that the DIRTY_FB ioctl should be used. 2011 - */ 2012 - struct drm_property *dirty_info_property; 2013 - 2014 - /** 2015 2653 * @degamma_lut_property: Optional CRTC property to set the LUT used to 2016 2654 * convert the framebuffer's colors to linear gamma. 2017 2655 */ ··· 2091 2741 for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder))) 2092 2742 2093 2743 #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) 2094 - #define obj_to_connector(x) container_of(x, struct drm_connector, base) 2095 2744 #define obj_to_encoder(x) container_of(x, struct drm_encoder, base) 2096 2745 #define obj_to_mode(x) container_of(x, struct drm_display_mode, base) 2097 2746 #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) ··· 2134 2785 static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc) 2135 2786 { 2136 2787 return 1 << drm_crtc_index(crtc); 2137 - } 2138 - 2139 - int drm_connector_init(struct drm_device *dev, 2140 - struct drm_connector *connector, 2141 - const struct drm_connector_funcs *funcs, 2142 - int connector_type); 2143 - int drm_connector_register(struct drm_connector *connector); 2144 - void drm_connector_unregister(struct drm_connector *connector); 2145 - 2146 - extern void drm_connector_cleanup(struct drm_connector *connector); 2147 - static inline unsigned drm_connector_index(struct drm_connector *connector) 2148 - { 2149 - return connector->index; 2150 2788 } 2151 2789 2152 2790 extern __printf(5, 6) ··· 2204 2868 2205 2869 extern void drm_encoder_cleanup(struct drm_encoder *encoder); 2206 2870 2207 - extern const char *drm_get_connector_status_name(enum drm_connector_status status); 2208 - extern const char *drm_get_subpixel_order_name(enum subpixel_order order); 2209 - extern const char *drm_get_dpms_name(int val); 2210 - extern const char *drm_get_dvi_i_subconnector_name(int val); 2211 - extern const char *drm_get_dvi_i_select_name(int val); 2212 - extern const char *drm_get_tv_subconnector_name(int val); 2213 - extern const char *drm_get_tv_select_name(int val); 2214 2871 extern void drm_mode_config_init(struct drm_device *dev); 2215 2872 extern void drm_mode_config_reset(struct drm_device *dev); 2216 2873 extern void drm_mode_config_cleanup(struct drm_device *dev); 2217 - 2218 - extern int drm_mode_connector_set_path_property(struct drm_connector *connector, 2219 - const char *path); 2220 - int drm_mode_connector_set_tile_property(struct drm_connector *connector); 2221 - extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, 2222 - const struct edid *edid); 2223 - 2224 - extern int drm_display_info_set_bus_formats(struct drm_display_info *info, 2225 - const u32 *formats, 2226 - unsigned int num_formats); 2227 2874 2228 2875 static inline bool drm_property_type_is(struct drm_property *property, 2229 2876 uint32_t type) ··· 2223 2904 extern int drm_object_property_get_value(struct drm_mode_object *obj, 2224 2905 struct drm_property *property, 2225 2906 uint64_t *value); 2226 - extern int drm_framebuffer_init(struct drm_device *dev, 2227 - struct drm_framebuffer *fb, 2228 - const struct drm_framebuffer_funcs *funcs); 2229 - extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, 2230 - uint32_t id); 2231 - extern void drm_framebuffer_remove(struct drm_framebuffer *fb); 2232 - extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); 2233 - extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); 2234 2907 2235 2908 extern void drm_object_attach_property(struct drm_mode_object *obj, 2236 2909 struct drm_property *property, ··· 2253 2942 const void *data); 2254 2943 struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev, 2255 2944 uint32_t id); 2945 + int drm_property_replace_global_blob(struct drm_device *dev, 2946 + struct drm_property_blob **replace, 2947 + size_t length, 2948 + const void *data, 2949 + struct drm_mode_object *obj_holds_id, 2950 + struct drm_property *prop_holds_id); 2256 2951 struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob); 2257 2952 void drm_property_unreference_blob(struct drm_property_blob *blob); 2258 2953 extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); 2259 2954 extern int drm_property_add_enum(struct drm_property *property, int index, 2260 2955 uint64_t value, const char *name); 2261 - extern int drm_mode_create_dvi_i_properties(struct drm_device *dev); 2262 - extern int drm_mode_create_tv_properties(struct drm_device *dev, 2263 - unsigned int num_modes, 2264 - const char * const modes[]); 2265 - extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); 2266 - extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev); 2267 - extern int drm_mode_create_dirty_info_property(struct drm_device *dev); 2268 - extern int drm_mode_create_suggested_offset_properties(struct drm_device *dev); 2269 - 2270 - extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, 2271 - struct drm_encoder *encoder); 2272 2956 extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, 2273 2957 int gamma_size); 2274 2958 ··· 2299 2993 unsigned int zpos); 2300 2994 2301 2995 /* Helpers */ 2302 - struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, 2303 - uint32_t id, uint32_t type); 2304 - void drm_mode_object_reference(struct drm_mode_object *obj); 2305 - void drm_mode_object_unreference(struct drm_mode_object *obj); 2306 - 2307 2996 static inline struct drm_plane *drm_plane_find(struct drm_device *dev, 2308 2997 uint32_t id) 2309 2998 { ··· 2321 3020 struct drm_mode_object *mo; 2322 3021 mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER); 2323 3022 return mo ? obj_to_encoder(mo) : NULL; 2324 - } 2325 - 2326 - /** 2327 - * drm_connector_lookup - lookup connector object 2328 - * @dev: DRM device 2329 - * @id: connector object id 2330 - * 2331 - * This function looks up the connector object specified by id 2332 - * add takes a reference to it. 2333 - */ 2334 - static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev, 2335 - uint32_t id) 2336 - { 2337 - struct drm_mode_object *mo; 2338 - mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR); 2339 - return mo ? obj_to_connector(mo) : NULL; 2340 3023 } 2341 3024 2342 3025 static inline struct drm_property *drm_property_find(struct drm_device *dev, ··· 2348 3063 } 2349 3064 2350 3065 return clamp_val(val, 0, max); 2351 - } 2352 - 2353 - /** 2354 - * drm_framebuffer_reference - incr the fb refcnt 2355 - * @fb: framebuffer 2356 - * 2357 - * This functions increments the fb's refcount. 2358 - */ 2359 - static inline void drm_framebuffer_reference(struct drm_framebuffer *fb) 2360 - { 2361 - drm_mode_object_reference(&fb->base); 2362 - } 2363 - 2364 - /** 2365 - * drm_framebuffer_unreference - unref a framebuffer 2366 - * @fb: framebuffer to unref 2367 - * 2368 - * This functions decrements the fb's refcount and frees it if it drops to zero. 2369 - */ 2370 - static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb) 2371 - { 2372 - drm_mode_object_unreference(&fb->base); 2373 - } 2374 - 2375 - /** 2376 - * drm_framebuffer_read_refcount - read the framebuffer reference count. 2377 - * @fb: framebuffer 2378 - * 2379 - * This functions returns the framebuffer's reference count. 2380 - */ 2381 - static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb) 2382 - { 2383 - return atomic_read(&fb->base.refcount.refcount); 2384 - } 2385 - 2386 - /** 2387 - * drm_connector_reference - incr the connector refcnt 2388 - * @connector: connector 2389 - * 2390 - * This function increments the connector's refcount. 2391 - */ 2392 - static inline void drm_connector_reference(struct drm_connector *connector) 2393 - { 2394 - drm_mode_object_reference(&connector->base); 2395 - } 2396 - 2397 - /** 2398 - * drm_connector_unreference - unref a connector 2399 - * @connector: connector to unref 2400 - * 2401 - * This function decrements the connector's refcount and frees it if it drops to zero. 2402 - */ 2403 - static inline void drm_connector_unreference(struct drm_connector *connector) 2404 - { 2405 - drm_mode_object_unreference(&connector->base); 2406 3066 } 2407 3067 2408 3068 /* Plane list iterator for legacy (overlay only) planes. */
+1 -5
include/drm/drm_crtc_helper.h
··· 41 41 42 42 #include <drm/drm_crtc.h> 43 43 #include <drm/drm_modeset_helper_vtables.h> 44 + #include <drm/drm_modeset_helper.h> 44 45 45 46 extern void drm_helper_disable_unused_functions(struct drm_device *dev); 46 47 extern int drm_crtc_helper_set_config(struct drm_mode_set *set); ··· 53 52 extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder); 54 53 55 54 extern int drm_helper_connector_dpms(struct drm_connector *connector, int mode); 56 - 57 - extern void drm_helper_move_panel_connectors_to_head(struct drm_device *); 58 - 59 - extern void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, 60 - const struct drm_mode_fb_cmd2 *mode_cmd); 61 55 62 56 extern void drm_helper_resume_force_mode(struct drm_device *dev); 63 57
+16 -20
include/drm/drm_dp_aux_dev.h drivers/gpu/drm/drm_crtc_helper_internal.h
··· 1 1 /* 2 - * Copyright © 2015 Intel Corporation 2 + * Copyright © 2016 Intel Corporation 3 3 * 4 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 5 * copy of this software and associated documentation files (the "Software"), ··· 8 8 * and/or sell copies of the Software, and to permit persons to whom the 9 9 * Software is furnished to do so, subject to the following conditions: 10 10 * 11 - * The above copyright notice and this permission notice (including the next 12 - * paragraph) shall be included in all copies or substantial portions of the 13 - * Software. 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 14 13 * 15 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 - * IN THE SOFTWARE. 22 - * 23 - * Authors: 24 - * Rafael Antognolli <rafael.antognolli@intel.com> 25 - * 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 26 21 */ 27 22 28 - #ifndef DRM_DP_AUX_DEV 29 - #define DRM_DP_AUX_DEV 23 + /* 24 + * This header file contains mode setting related functions and definitions 25 + * which are only used within the drm kms helper module as internal 26 + * implementation details and are not exported to drivers. 27 + */ 30 28 31 29 #include <drm/drm_dp_helper.h> 32 30 33 - #ifdef CONFIG_DRM_DP_AUX_CHARDEV 31 + /* drm_fb_helper.c */ 32 + int drm_fb_helper_modinit(void); 34 33 34 + /* drm_dp_aux_dev.c */ 35 + #ifdef CONFIG_DRM_DP_AUX_CHARDEV 35 36 int drm_dp_aux_dev_init(void); 36 37 void drm_dp_aux_dev_exit(void); 37 38 int drm_dp_aux_register_devnode(struct drm_dp_aux *aux); 38 39 void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux); 39 - 40 40 #else 41 - 42 41 static inline int drm_dp_aux_dev_init(void) 43 42 { 44 43 return 0; ··· 55 56 static inline void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux) 56 57 { 57 58 } 58 - 59 - #endif 60 - 61 59 #endif
+18 -10
include/drm/drm_fb_helper.h
··· 177 177 * the screen buffer 178 178 * @dirty_lock: spinlock protecting @dirty_clip 179 179 * @dirty_work: worker used to flush the framebuffer 180 + * @resume_work: worker used during resume if the console lock is already taken 180 181 * 181 182 * This is the main structure used by the fbdev helpers. Drivers supporting 182 183 * fbdev emulation should embedded this into their overall driver structure. ··· 198 197 struct drm_clip_rect dirty_clip; 199 198 spinlock_t dirty_lock; 200 199 struct work_struct dirty_work; 200 + struct work_struct resume_work; 201 201 202 202 /** 203 203 * @kernel_fb_list: ··· 218 216 }; 219 217 220 218 #ifdef CONFIG_DRM_FBDEV_EMULATION 221 - int drm_fb_helper_modinit(void); 222 219 void drm_fb_helper_prepare(struct drm_device *dev, struct drm_fb_helper *helper, 223 220 const struct drm_fb_helper_funcs *funcs); 224 221 int drm_fb_helper_init(struct drm_device *dev, ··· 265 264 void drm_fb_helper_cfb_imageblit(struct fb_info *info, 266 265 const struct fb_image *image); 267 266 268 - void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, int state); 267 + void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, bool suspend); 268 + void drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper, 269 + bool suspend); 269 270 270 271 int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); 271 272 ··· 286 283 int drm_fb_helper_add_one_connector(struct drm_fb_helper *fb_helper, struct drm_connector *connector); 287 284 int drm_fb_helper_remove_one_connector(struct drm_fb_helper *fb_helper, 288 285 struct drm_connector *connector); 289 - static inline int 290 - drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, 291 - const char *name, bool primary) 292 - { 293 - return remove_conflicting_framebuffers(a, name, primary); 294 - } 295 286 #else 296 287 static inline int drm_fb_helper_modinit(void) 297 288 { ··· 421 424 } 422 425 423 426 static inline void drm_fb_helper_set_suspend(struct drm_fb_helper *fb_helper, 424 - int state) 427 + bool suspend) 428 + { 429 + } 430 + 431 + static inline void 432 + drm_fb_helper_set_suspend_unlocked(struct drm_fb_helper *fb_helper, bool suspend) 425 433 { 426 434 } 427 435 ··· 485 483 return 0; 486 484 } 487 485 486 + #endif 487 + 488 488 static inline int 489 489 drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, 490 490 const char *name, bool primary) 491 491 { 492 + #if IS_ENABLED(CONFIG_FB) 493 + return remove_conflicting_framebuffers(a, name, primary); 494 + #else 492 495 return 0; 493 - } 494 496 #endif 497 + } 498 + 495 499 #endif
+1 -1
include/drm/drm_fourcc.h
··· 32 32 int drm_format_vert_chroma_subsampling(uint32_t format); 33 33 int drm_format_plane_width(int width, uint32_t format, int plane); 34 34 int drm_format_plane_height(int height, uint32_t format, int plane); 35 - const char *drm_get_format_name(uint32_t format); 35 + char *drm_get_format_name(uint32_t format) __malloc; 36 36 37 37 #endif /* __DRM_FOURCC_H__ */
+250
include/drm/drm_framebuffer.h
··· 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 + #ifndef __DRM_FRAMEBUFFER_H__ 24 + #define __DRM_FRAMEBUFFER_H__ 25 + 26 + #include <linux/list.h> 27 + #include <linux/ctype.h> 28 + #include <drm/drm_modeset.h> 29 + 30 + struct drm_framebuffer; 31 + struct drm_file; 32 + struct drm_device; 33 + 34 + /** 35 + * struct drm_framebuffer_funcs - framebuffer hooks 36 + */ 37 + struct drm_framebuffer_funcs { 38 + /** 39 + * @destroy: 40 + * 41 + * Clean up framebuffer resources, specifically also unreference the 42 + * backing storage. The core guarantees to call this function for every 43 + * framebuffer successfully created by ->fb_create() in 44 + * &drm_mode_config_funcs. Drivers must also call 45 + * drm_framebuffer_cleanup() to release DRM core resources for this 46 + * framebuffer. 47 + */ 48 + void (*destroy)(struct drm_framebuffer *framebuffer); 49 + 50 + /** 51 + * @create_handle: 52 + * 53 + * Create a buffer handle in the driver-specific buffer manager (either 54 + * GEM or TTM) valid for the passed-in struct &drm_file. This is used by 55 + * the core to implement the GETFB IOCTL, which returns (for 56 + * sufficiently priviledged user) also a native buffer handle. This can 57 + * be used for seamless transitions between modesetting clients by 58 + * copying the current screen contents to a private buffer and blending 59 + * between that and the new contents. 60 + * 61 + * GEM based drivers should call drm_gem_handle_create() to create the 62 + * handle. 63 + * 64 + * RETURNS: 65 + * 66 + * 0 on success or a negative error code on failure. 67 + */ 68 + int (*create_handle)(struct drm_framebuffer *fb, 69 + struct drm_file *file_priv, 70 + unsigned int *handle); 71 + /** 72 + * @dirty: 73 + * 74 + * Optional callback for the dirty fb IOCTL. 75 + * 76 + * Userspace can notify the driver via this callback that an area of the 77 + * framebuffer has changed and should be flushed to the display 78 + * hardware. This can also be used internally, e.g. by the fbdev 79 + * emulation, though that's not the case currently. 80 + * 81 + * See documentation in drm_mode.h for the struct drm_mode_fb_dirty_cmd 82 + * for more information as all the semantics and arguments have a one to 83 + * one mapping on this function. 84 + * 85 + * RETURNS: 86 + * 87 + * 0 on success or a negative error code on failure. 88 + */ 89 + int (*dirty)(struct drm_framebuffer *framebuffer, 90 + struct drm_file *file_priv, unsigned flags, 91 + unsigned color, struct drm_clip_rect *clips, 92 + unsigned num_clips); 93 + }; 94 + 95 + /** 96 + * struct drm_framebuffer - frame buffer object 97 + * 98 + * Note that the fb is refcounted for the benefit of driver internals, 99 + * for example some hw, disabling a CRTC/plane is asynchronous, and 100 + * scanout does not actually complete until the next vblank. So some 101 + * cleanup (like releasing the reference(s) on the backing GEM bo(s)) 102 + * should be deferred. In cases like this, the driver would like to 103 + * hold a ref to the fb even though it has already been removed from 104 + * userspace perspective. See drm_framebuffer_reference() and 105 + * drm_framebuffer_unreference(). 106 + * 107 + * The refcount is stored inside the mode object @base. 108 + */ 109 + struct drm_framebuffer { 110 + /** 111 + * @dev: DRM device this framebuffer belongs to 112 + */ 113 + struct drm_device *dev; 114 + /** 115 + * @head: Place on the dev->mode_config.fb_list, access protected by 116 + * dev->mode_config.fb_lock. 117 + */ 118 + struct list_head head; 119 + 120 + /** 121 + * @base: base modeset object structure, contains the reference count. 122 + */ 123 + struct drm_mode_object base; 124 + /** 125 + * @funcs: framebuffer vfunc table 126 + */ 127 + const struct drm_framebuffer_funcs *funcs; 128 + /** 129 + * @pitches: Line stride per buffer. For userspace created object this 130 + * is copied from drm_mode_fb_cmd2. 131 + */ 132 + unsigned int pitches[4]; 133 + /** 134 + * @offsets: Offset from buffer start to the actual pixel data in bytes, 135 + * per buffer. For userspace created object this is copied from 136 + * drm_mode_fb_cmd2. 137 + * 138 + * Note that this is a linear offset and does not take into account 139 + * tiling or buffer laytou per @modifier. It meant to be used when the 140 + * actual pixel data for this framebuffer plane starts at an offset, 141 + * e.g. when multiple planes are allocated within the same backing 142 + * storage buffer object. For tiled layouts this generally means it 143 + * @offsets must at least be tile-size aligned, but hardware often has 144 + * stricter requirements. 145 + * 146 + * This should not be used to specifiy x/y pixel offsets into the buffer 147 + * data (even for linear buffers). Specifying an x/y pixel offset is 148 + * instead done through the source rectangle in struct &drm_plane_state. 149 + */ 150 + unsigned int offsets[4]; 151 + /** 152 + * @modifier: Data layout modifier, per buffer. This is used to describe 153 + * tiling, or also special layouts (like compression) of auxiliary 154 + * buffers. For userspace created object this is copied from 155 + * drm_mode_fb_cmd2. 156 + */ 157 + uint64_t modifier[4]; 158 + /** 159 + * @width: Logical width of the visible area of the framebuffer, in 160 + * pixels. 161 + */ 162 + unsigned int width; 163 + /** 164 + * @height: Logical height of the visible area of the framebuffer, in 165 + * pixels. 166 + */ 167 + unsigned int height; 168 + /** 169 + * @depth: Depth in bits per pixel for RGB formats. 0 for everything 170 + * else. Legacy information derived from @pixel_format, it's suggested to use 171 + * the DRM FOURCC codes and helper functions directly instead. 172 + */ 173 + unsigned int depth; 174 + /** 175 + * @bits_per_pixel: Storage used bits per pixel for RGB formats. 0 for 176 + * everything else. Legacy information derived from @pixel_format, it's 177 + * suggested to use the DRM FOURCC codes and helper functions directly 178 + * instead. 179 + */ 180 + int bits_per_pixel; 181 + /** 182 + * @flags: Framebuffer flags like DRM_MODE_FB_INTERLACED or 183 + * DRM_MODE_FB_MODIFIERS. 184 + */ 185 + int flags; 186 + /** 187 + * @pixel_format: DRM FOURCC code describing the pixel format. 188 + */ 189 + uint32_t pixel_format; /* fourcc format */ 190 + /** 191 + * @hot_x: X coordinate of the cursor hotspot. Used by the legacy cursor 192 + * IOCTL when the driver supports cursor through a DRM_PLANE_TYPE_CURSOR 193 + * universal plane. 194 + */ 195 + int hot_x; 196 + /** 197 + * @hot_y: Y coordinate of the cursor hotspot. Used by the legacy cursor 198 + * IOCTL when the driver supports cursor through a DRM_PLANE_TYPE_CURSOR 199 + * universal plane. 200 + */ 201 + int hot_y; 202 + /** 203 + * @filp_head: Placed on struct &drm_file fbs list_head, protected by 204 + * fbs_lock in the same structure. 205 + */ 206 + struct list_head filp_head; 207 + }; 208 + 209 + int drm_framebuffer_init(struct drm_device *dev, 210 + struct drm_framebuffer *fb, 211 + const struct drm_framebuffer_funcs *funcs); 212 + struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, 213 + uint32_t id); 214 + void drm_framebuffer_remove(struct drm_framebuffer *fb); 215 + void drm_framebuffer_cleanup(struct drm_framebuffer *fb); 216 + void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); 217 + 218 + /** 219 + * drm_framebuffer_reference - incr the fb refcnt 220 + * @fb: framebuffer 221 + * 222 + * This functions increments the fb's refcount. 223 + */ 224 + static inline void drm_framebuffer_reference(struct drm_framebuffer *fb) 225 + { 226 + drm_mode_object_reference(&fb->base); 227 + } 228 + 229 + /** 230 + * drm_framebuffer_unreference - unref a framebuffer 231 + * @fb: framebuffer to unref 232 + * 233 + * This functions decrements the fb's refcount and frees it if it drops to zero. 234 + */ 235 + static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb) 236 + { 237 + drm_mode_object_unreference(&fb->base); 238 + } 239 + 240 + /** 241 + * drm_framebuffer_read_refcount - read the framebuffer reference count. 242 + * @fb: framebuffer 243 + * 244 + * This functions returns the framebuffer's reference count. 245 + */ 246 + static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb) 247 + { 248 + return atomic_read(&fb->base.refcount.refcount); 249 + } 250 + #endif
+2 -2
include/drm/drm_gem.h
··· 210 210 * drm_gem_object_unreference_unlocked(). 211 211 * 212 212 * Drivers should never call this directly in their code. Instead they should 213 - * wrap it up into a driver_gem_object_unreference(struct driver_gem_object 214 - * *obj) wrapper function, and use that. Shared code should never call this, to 213 + * wrap it up into a ``driver_gem_object_unreference(struct driver_gem_object 214 + * *obj)`` wrapper function, and use that. Shared code should never call this, to 215 215 * avoid breaking drivers by accident which still depend upon dev->struct_mutex 216 216 * locking. 217 217 */
+3 -15
include/drm/drm_modes.h
··· 27 27 #ifndef __DRM_MODES_H__ 28 28 #define __DRM_MODES_H__ 29 29 30 + #include <drm/drm_modeset.h> 31 + #include <drm/drm_connector.h> 32 + 30 33 /* 31 34 * Note on terminology: here, for brevity and convenience, we refer to connector 32 35 * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, ··· 401 398 * Field for setting the HDMI picture aspect ratio of a mode. 402 399 */ 403 400 enum hdmi_picture_aspect picture_aspect_ratio; 404 - }; 405 - 406 - /* mode specified on the command line */ 407 - struct drm_cmdline_mode { 408 - bool specified; 409 - bool refresh_specified; 410 - bool bpp_specified; 411 - int xres, yres; 412 - int bpp; 413 - int refresh; 414 - bool rb; 415 - bool interlace; 416 - bool cvt; 417 - bool margins; 418 - enum drm_connector_force force; 419 401 }; 420 402 421 403 /**
+70
include/drm/drm_modeset.h
··· 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 + #ifndef __DRM_MODESET_H__ 24 + #define __DRM_MODESET_H__ 25 + 26 + #include <linux/kref.h> 27 + struct drm_object_properties; 28 + struct drm_property; 29 + 30 + struct drm_mode_object { 31 + uint32_t id; 32 + uint32_t type; 33 + struct drm_object_properties *properties; 34 + struct kref refcount; 35 + void (*free_cb)(struct kref *kref); 36 + }; 37 + 38 + #define DRM_OBJECT_MAX_PROPERTY 24 39 + struct drm_object_properties { 40 + int count, atomic_count; 41 + /* NOTE: if we ever start dynamically destroying properties (ie. 42 + * not at drm_mode_config_cleanup() time), then we'd have to do 43 + * a better job of detaching property from mode objects to avoid 44 + * dangling property pointers: 45 + */ 46 + struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY]; 47 + /* do not read/write values directly, but use drm_object_property_get_value() 48 + * and drm_object_property_set_value(): 49 + */ 50 + uint64_t values[DRM_OBJECT_MAX_PROPERTY]; 51 + }; 52 + 53 + /* Avoid boilerplate. I'm tired of typing. */ 54 + #define DRM_ENUM_NAME_FN(fnname, list) \ 55 + const char *fnname(int val) \ 56 + { \ 57 + int i; \ 58 + for (i = 0; i < ARRAY_SIZE(list); i++) { \ 59 + if (list[i].type == val) \ 60 + return list[i].name; \ 61 + } \ 62 + return "(unknown)"; \ 63 + } 64 + 65 + struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, 66 + uint32_t id, uint32_t type); 67 + void drm_mode_object_reference(struct drm_mode_object *obj); 68 + void drm_mode_object_unreference(struct drm_mode_object *obj); 69 + 70 + #endif
+36
include/drm/drm_modeset_helper.h
··· 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 + #ifndef __DRM_KMS_HELPER_H__ 24 + #define __DRM_KMS_HELPER_H__ 25 + 26 + #include <drm/drmP.h> 27 + 28 + void drm_helper_move_panel_connectors_to_head(struct drm_device *); 29 + 30 + void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, 31 + const struct drm_mode_fb_cmd2 *mode_cmd); 32 + 33 + int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, 34 + const struct drm_crtc_funcs *funcs); 35 + 36 + #endif
+2 -2
include/drm/drm_modeset_helper_vtables.h
··· 855 855 * everything else must complete successfully. 856 856 */ 857 857 int (*prepare_fb)(struct drm_plane *plane, 858 - const struct drm_plane_state *new_state); 858 + struct drm_plane_state *new_state); 859 859 /** 860 860 * @cleanup_fb: 861 861 * ··· 866 866 * transitional plane helpers, but it is optional. 867 867 */ 868 868 void (*cleanup_fb)(struct drm_plane *plane, 869 - const struct drm_plane_state *old_state); 869 + struct drm_plane_state *old_state); 870 870 871 871 /** 872 872 * @atomic_check:
+1 -3
include/drm/drm_plane_helper.h
··· 27 27 #include <drm/drm_rect.h> 28 28 #include <drm/drm_crtc.h> 29 29 #include <drm/drm_modeset_helper_vtables.h> 30 + #include <drm/drm_modeset_helper.h> 30 31 31 32 /* 32 33 * Drivers that don't allow primary plane scaling may pass this macro in place ··· 37 36 * 1<<16 represents no scaling. 38 37 */ 39 38 #define DRM_PLANE_HELPER_NO_SCALING (1<<16) 40 - 41 - int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, 42 - const struct drm_crtc_funcs *funcs); 43 39 44 40 int drm_plane_helper_check_state(struct drm_plane_state *state, 45 41 const struct drm_rect *clip,
+16 -112
include/linux/vgaarb.h
··· 73 73 unsigned int decodes) { }; 74 74 #endif 75 75 76 - /** 77 - * vga_get - acquire & locks VGA resources 78 - * 79 - * @pdev: pci device of the VGA card or NULL for the system default 80 - * @rsrc: bit mask of resources to acquire and lock 81 - * @interruptible: blocking should be interruptible by signals ? 82 - * 83 - * This function acquires VGA resources for the given 84 - * card and mark those resources locked. If the resource requested 85 - * are "normal" (and not legacy) resources, the arbiter will first check 86 - * whether the card is doing legacy decoding for that type of resource. If 87 - * yes, the lock is "converted" into a legacy resource lock. 88 - * The arbiter will first look for all VGA cards that might conflict 89 - * and disable their IOs and/or Memory access, including VGA forwarding 90 - * on P2P bridges if necessary, so that the requested resources can 91 - * be used. Then, the card is marked as locking these resources and 92 - * the IO and/or Memory accesse are enabled on the card (including 93 - * VGA forwarding on parent P2P bridges if any). 94 - * This function will block if some conflicting card is already locking 95 - * one of the required resources (or any resource on a different bus 96 - * segment, since P2P bridges don't differenciate VGA memory and IO 97 - * afaik). You can indicate whether this blocking should be interruptible 98 - * by a signal (for userland interface) or not. 99 - * Must not be called at interrupt time or in atomic context. 100 - * If the card already owns the resources, the function succeeds. 101 - * Nested calls are supported (a per-resource counter is maintained) 102 - */ 103 - 104 76 #if defined(CONFIG_VGA_ARB) 105 77 extern int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible); 106 78 #else ··· 80 108 #endif 81 109 82 110 /** 83 - * vga_get_interruptible 111 + * vga_get_interruptible 112 + * @pdev: pci device of the VGA card or NULL for the system default 113 + * @rsrc: bit mask of resources to acquire and lock 84 114 * 85 - * Shortcut to vga_get 115 + * Shortcut to vga_get with interruptible set to true. 116 + * 117 + * On success, release the VGA resource again with vga_put(). 86 118 */ 87 - 88 119 static inline int vga_get_interruptible(struct pci_dev *pdev, 89 120 unsigned int rsrc) 90 121 { ··· 95 120 } 96 121 97 122 /** 98 - * vga_get_uninterruptible 123 + * vga_get_uninterruptible - shortcut to vga_get() 124 + * @pdev: pci device of the VGA card or NULL for the system default 125 + * @rsrc: bit mask of resources to acquire and lock 99 126 * 100 - * Shortcut to vga_get 127 + * Shortcut to vga_get with interruptible set to false. 128 + * 129 + * On success, release the VGA resource again with vga_put(). 101 130 */ 102 - 103 131 static inline int vga_get_uninterruptible(struct pci_dev *pdev, 104 132 unsigned int rsrc) 105 133 { 106 134 return vga_get(pdev, rsrc, 0); 107 135 } 108 - 109 - /** 110 - * vga_tryget - try to acquire & lock legacy VGA resources 111 - * 112 - * @pdev: pci devivce of VGA card or NULL for system default 113 - * @rsrc: bit mask of resources to acquire and lock 114 - * 115 - * This function performs the same operation as vga_get(), but 116 - * will return an error (-EBUSY) instead of blocking if the resources 117 - * are already locked by another card. It can be called in any context 118 - */ 119 136 120 137 #if defined(CONFIG_VGA_ARB) 121 138 extern int vga_tryget(struct pci_dev *pdev, unsigned int rsrc); ··· 115 148 static inline int vga_tryget(struct pci_dev *pdev, unsigned int rsrc) { return 0; } 116 149 #endif 117 150 118 - /** 119 - * vga_put - release lock on legacy VGA resources 120 - * 121 - * @pdev: pci device of VGA card or NULL for system default 122 - * @rsrc: but mask of resource to release 123 - * 124 - * This function releases resources previously locked by vga_get() 125 - * or vga_tryget(). The resources aren't disabled right away, so 126 - * that a subsequence vga_get() on the same card will succeed 127 - * immediately. Resources have a counter, so locks are only 128 - * released if the counter reaches 0. 129 - */ 130 - 131 151 #if defined(CONFIG_VGA_ARB) 132 152 extern void vga_put(struct pci_dev *pdev, unsigned int rsrc); 133 153 #else 134 154 #define vga_put(pdev, rsrc) 135 155 #endif 136 156 137 - 138 - /** 139 - * vga_default_device 140 - * 141 - * This can be defined by the platform. The default implementation 142 - * is rather dumb and will probably only work properly on single 143 - * vga card setups and/or x86 platforms. 144 - * 145 - * If your VGA default device is not PCI, you'll have to return 146 - * NULL here. In this case, I assume it will not conflict with 147 - * any PCI card. If this is not true, I'll have to define two archs 148 - * hooks for enabling/disabling the VGA default device if that is 149 - * possible. This may be a problem with real _ISA_ VGA cards, in 150 - * addition to a PCI one. I don't know at this point how to deal 151 - * with that card. Can theirs IOs be disabled at all ? If not, then 152 - * I suppose it's a matter of having the proper arch hook telling 153 - * us about it, so we basically never allow anybody to succeed a 154 - * vga_get()... 155 - */ 156 157 157 158 #ifdef CONFIG_VGA_ARB 158 159 extern struct pci_dev *vga_default_device(void); ··· 130 195 static inline void vga_set_default_device(struct pci_dev *pdev) { }; 131 196 #endif 132 197 133 - /** 134 - * vga_conflicts 135 - * 136 - * Architectures should define this if they have several 137 - * independent PCI domains that can afford concurrent VGA 138 - * decoding 198 + /* 199 + * Architectures should define this if they have several 200 + * independent PCI domains that can afford concurrent VGA 201 + * decoding 139 202 */ 140 - 141 203 #ifndef __ARCH_HAS_VGA_CONFLICT 142 204 static inline int vga_conflicts(struct pci_dev *p1, struct pci_dev *p2) 143 205 { ··· 142 210 } 143 211 #endif 144 212 145 - /** 146 - * vga_client_register 147 - * 148 - * @pdev: pci device of the VGA client 149 - * @cookie: client cookie to be used in callbacks 150 - * @irq_set_state: irq state change callback 151 - * @set_vga_decode: vga decode change callback 152 - * 153 - * return value: 0 on success, -1 on failure 154 - * Register a client with the VGA arbitration logic 155 - * 156 - * Clients have two callback mechanisms they can use. 157 - * irq enable/disable callback - 158 - * If a client can't disable its GPUs VGA resources, then we 159 - * need to be able to ask it to turn off its irqs when we 160 - * turn off its mem and io decoding. 161 - * set_vga_decode 162 - * If a client can disable its GPU VGA resource, it will 163 - * get a callback from this to set the encode/decode state 164 - * 165 - * Rationale: we cannot disable VGA decode resources unconditionally 166 - * some single GPU laptops seem to require ACPI or BIOS access to the 167 - * VGA registers to control things like backlights etc. 168 - * Hopefully newer multi-GPU laptops do something saner, and desktops 169 - * won't have any special ACPI for this. 170 - * They driver will get a callback when VGA arbitration is first used 171 - * by userspace since we some older X servers have issues. 172 - */ 173 213 #if defined(CONFIG_VGA_ARB) 174 214 int vga_client_register(struct pci_dev *pdev, void *cookie, 175 215 void (*irq_set_state)(void *cookie, bool state),