drm_connector.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  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. #ifndef __DRM_CONNECTOR_H__
  23. #define __DRM_CONNECTOR_H__
  24. #include <linux/list.h>
  25. #include <linux/ctype.h>
  26. #include <drm/drm_mode_object.h>
  27. #include <uapi/drm/drm_mode.h>
  28. struct drm_device;
  29. struct drm_connector_helper_funcs;
  30. struct drm_modeset_acquire_ctx;
  31. struct drm_device;
  32. struct drm_crtc;
  33. struct drm_encoder;
  34. struct drm_property;
  35. struct drm_property_blob;
  36. struct drm_printer;
  37. struct edid;
  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. * enum drm_connector_status - status for a &drm_connector
  46. *
  47. * This enum is used to track the connector status. There are no separate
  48. * #defines for the uapi!
  49. */
  50. enum drm_connector_status {
  51. /**
  52. * @connector_status_connected: The connector is definitely connected to
  53. * a sink device, and can be enabled.
  54. */
  55. connector_status_connected = 1,
  56. /**
  57. * @connector_status_disconnected: The connector isn't connected to a
  58. * sink device which can be autodetect. For digital outputs like DP or
  59. * HDMI (which can be realiable probed) this means there's really
  60. * nothing there. It is driver-dependent whether a connector with this
  61. * status can be lit up or not.
  62. */
  63. connector_status_disconnected = 2,
  64. /**
  65. * @connector_status_unknown: The connector's status could not be
  66. * reliably detected. This happens when probing would either cause
  67. * flicker (like load-detection when the connector is in use), or when a
  68. * hardware resource isn't available (like when load-detection needs a
  69. * free CRTC). It should be possible to light up the connector with one
  70. * of the listed fallback modes. For default configuration userspace
  71. * should only try to light up connectors with unknown status when
  72. * there's not connector with @connector_status_connected.
  73. */
  74. connector_status_unknown = 3,
  75. };
  76. enum subpixel_order {
  77. SubPixelUnknown = 0,
  78. SubPixelHorizontalRGB,
  79. SubPixelHorizontalBGR,
  80. SubPixelVerticalRGB,
  81. SubPixelVerticalBGR,
  82. SubPixelNone,
  83. };
  84. /**
  85. * struct drm_scrambling: sink's scrambling support.
  86. */
  87. struct drm_scrambling {
  88. /**
  89. * @supported: scrambling supported for rates > 340 Mhz.
  90. */
  91. bool supported;
  92. /**
  93. * @low_rates: scrambling supported for rates <= 340 Mhz.
  94. */
  95. bool low_rates;
  96. };
  97. /*
  98. * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
  99. *
  100. * Provides SCDC register support and capabilities related information on a
  101. * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
  102. */
  103. struct drm_scdc {
  104. /**
  105. * @supported: status control & data channel present.
  106. */
  107. bool supported;
  108. /**
  109. * @read_request: sink is capable of generating scdc read request.
  110. */
  111. bool read_request;
  112. /**
  113. * @scrambling: sink's scrambling capabilities
  114. */
  115. struct drm_scrambling scrambling;
  116. };
  117. /**
  118. * struct drm_hdmi_info - runtime information about the connected HDMI sink
  119. *
  120. * Describes if a given display supports advanced HDMI 2.0 features.
  121. * This information is available in CEA-861-F extension blocks (like HF-VSDB).
  122. */
  123. struct drm_hdmi_info {
  124. /** @scdc: sink's scdc support and capabilities */
  125. struct drm_scdc scdc;
  126. };
  127. /**
  128. * enum drm_link_status - connector's link_status property value
  129. *
  130. * This enum is used as the connector's link status property value.
  131. * It is set to the values defined in uapi.
  132. *
  133. * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful
  134. * link training
  135. * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training
  136. * failure
  137. */
  138. enum drm_link_status {
  139. DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
  140. DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
  141. };
  142. /**
  143. * struct drm_display_info - runtime data about the connected sink
  144. *
  145. * Describes a given display (e.g. CRT or flat panel) and its limitations. For
  146. * fixed display sinks like built-in panels there's not much difference between
  147. * this and &struct drm_connector. But for sinks with a real cable this
  148. * structure is meant to describe all the things at the other end of the cable.
  149. *
  150. * For sinks which provide an EDID this can be filled out by calling
  151. * drm_add_edid_modes().
  152. */
  153. struct drm_display_info {
  154. /**
  155. * @name: Name of the display.
  156. */
  157. char name[DRM_DISPLAY_INFO_LEN];
  158. /**
  159. * @width_mm: Physical width in mm.
  160. */
  161. unsigned int width_mm;
  162. /**
  163. * @height_mm: Physical height in mm.
  164. */
  165. unsigned int height_mm;
  166. /**
  167. * @pixel_clock: Maximum pixel clock supported by the sink, in units of
  168. * 100Hz. This mismatches the clock in &drm_display_mode (which is in
  169. * kHZ), because that's what the EDID uses as base unit.
  170. */
  171. unsigned int pixel_clock;
  172. /**
  173. * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
  174. */
  175. unsigned int bpc;
  176. /**
  177. * @subpixel_order: Subpixel order of LCD panels.
  178. */
  179. enum subpixel_order subpixel_order;
  180. #define DRM_COLOR_FORMAT_RGB444 (1<<0)
  181. #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
  182. #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
  183. /**
  184. * @color_formats: HDMI Color formats, selects between RGB and YCrCb
  185. * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones
  186. * as used to describe the pixel format in framebuffers, and also don't
  187. * match the formats in @bus_formats which are shared with v4l.
  188. */
  189. u32 color_formats;
  190. /**
  191. * @bus_formats: Pixel data format on the wire, somewhat redundant with
  192. * @color_formats. Array of size @num_bus_formats encoded using
  193. * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
  194. */
  195. const u32 *bus_formats;
  196. /**
  197. * @num_bus_formats: Size of @bus_formats array.
  198. */
  199. unsigned int num_bus_formats;
  200. #define DRM_BUS_FLAG_DE_LOW (1<<0)
  201. #define DRM_BUS_FLAG_DE_HIGH (1<<1)
  202. /* drive data on pos. edge */
  203. #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2)
  204. /* drive data on neg. edge */
  205. #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3)
  206. /* data is transmitted MSB to LSB on the bus */
  207. #define DRM_BUS_FLAG_DATA_MSB_TO_LSB (1<<4)
  208. /* data is transmitted LSB to MSB on the bus */
  209. #define DRM_BUS_FLAG_DATA_LSB_TO_MSB (1<<5)
  210. /**
  211. * @bus_flags: Additional information (like pixel signal polarity) for
  212. * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines.
  213. */
  214. u32 bus_flags;
  215. /**
  216. * @max_tmds_clock: Maximum TMDS clock rate supported by the
  217. * sink in kHz. 0 means undefined.
  218. */
  219. int max_tmds_clock;
  220. /**
  221. * @dvi_dual: Dual-link DVI sink?
  222. */
  223. bool dvi_dual;
  224. /**
  225. * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
  226. * more stuff redundant with @bus_formats.
  227. */
  228. u8 edid_hdmi_dc_modes;
  229. /**
  230. * @cea_rev: CEA revision of the HDMI sink.
  231. */
  232. u8 cea_rev;
  233. /**
  234. * @hdmi: advance features of a HDMI sink.
  235. */
  236. struct drm_hdmi_info hdmi;
  237. };
  238. int drm_display_info_set_bus_formats(struct drm_display_info *info,
  239. const u32 *formats,
  240. unsigned int num_formats);
  241. /**
  242. * struct drm_tv_connector_state - TV connector related states
  243. * @subconnector: selected subconnector
  244. * @margins: left/right/top/bottom margins
  245. * @mode: TV mode
  246. * @brightness: brightness in percent
  247. * @contrast: contrast in percent
  248. * @flicker_reduction: flicker reduction in percent
  249. * @overscan: overscan in percent
  250. * @saturation: saturation in percent
  251. * @hue: hue in percent
  252. */
  253. struct drm_tv_connector_state {
  254. enum drm_mode_subconnector subconnector;
  255. struct {
  256. unsigned int left;
  257. unsigned int right;
  258. unsigned int top;
  259. unsigned int bottom;
  260. } margins;
  261. unsigned int mode;
  262. unsigned int brightness;
  263. unsigned int contrast;
  264. unsigned int flicker_reduction;
  265. unsigned int overscan;
  266. unsigned int saturation;
  267. unsigned int hue;
  268. };
  269. /**
  270. * struct drm_connector_state - mutable connector state
  271. * @connector: backpointer to the connector
  272. * @best_encoder: can be used by helpers and drivers to select the encoder
  273. * @state: backpointer to global drm_atomic_state
  274. * @tv: TV connector state
  275. */
  276. struct drm_connector_state {
  277. struct drm_connector *connector;
  278. /**
  279. * @crtc: CRTC to connect connector to, NULL if disabled.
  280. *
  281. * Do not change this directly, use drm_atomic_set_crtc_for_connector()
  282. * instead.
  283. */
  284. struct drm_crtc *crtc;
  285. struct drm_encoder *best_encoder;
  286. /**
  287. * @link_status: Connector link_status to keep track of whether link is
  288. * GOOD or BAD to notify userspace if retraining is necessary.
  289. */
  290. enum drm_link_status link_status;
  291. struct drm_atomic_state *state;
  292. struct drm_tv_connector_state tv;
  293. };
  294. /**
  295. * struct drm_connector_funcs - control connectors on a given device
  296. *
  297. * Each CRTC may have one or more connectors attached to it. The functions
  298. * below allow the core DRM code to control connectors, enumerate available modes,
  299. * etc.
  300. */
  301. struct drm_connector_funcs {
  302. /**
  303. * @dpms:
  304. *
  305. * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
  306. * is exposed as a standard property on the connector, but diverted to
  307. * this callback in the drm core. Note that atomic drivers don't
  308. * implement the 4 level DPMS support on the connector any more, but
  309. * instead only have an on/off "ACTIVE" property on the CRTC object.
  310. *
  311. * Drivers implementing atomic modeset should use
  312. * drm_atomic_helper_connector_dpms() to implement this hook.
  313. *
  314. * RETURNS:
  315. *
  316. * 0 on success or a negative error code on failure.
  317. */
  318. int (*dpms)(struct drm_connector *connector, int mode);
  319. /**
  320. * @reset:
  321. *
  322. * Reset connector hardware and software state to off. This function isn't
  323. * called by the core directly, only through drm_mode_config_reset().
  324. * It's not a helper hook only for historical reasons.
  325. *
  326. * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
  327. * atomic state using this hook.
  328. */
  329. void (*reset)(struct drm_connector *connector);
  330. /**
  331. * @detect:
  332. *
  333. * Check to see if anything is attached to the connector. The parameter
  334. * force is set to false whilst polling, true when checking the
  335. * connector due to a user request. force can be used by the driver to
  336. * avoid expensive, destructive operations during automated probing.
  337. *
  338. * This callback is optional, if not implemented the connector will be
  339. * considered as always being attached.
  340. *
  341. * FIXME:
  342. *
  343. * Note that this hook is only called by the probe helper. It's not in
  344. * the helper library vtable purely for historical reasons. The only DRM
  345. * core entry point to probe connector state is @fill_modes.
  346. *
  347. * Note that the helper library will already hold
  348. * &drm_mode_config.connection_mutex. Drivers which need to grab additional
  349. * locks to avoid races with concurrent modeset changes need to use
  350. * &drm_connector_helper_funcs.detect_ctx instead.
  351. *
  352. * RETURNS:
  353. *
  354. * drm_connector_status indicating the connector's status.
  355. */
  356. enum drm_connector_status (*detect)(struct drm_connector *connector,
  357. bool force);
  358. /**
  359. * @force:
  360. *
  361. * This function is called to update internal encoder state when the
  362. * connector is forced to a certain state by userspace, either through
  363. * the sysfs interfaces or on the kernel cmdline. In that case the
  364. * @detect callback isn't called.
  365. *
  366. * FIXME:
  367. *
  368. * Note that this hook is only called by the probe helper. It's not in
  369. * the helper library vtable purely for historical reasons. The only DRM
  370. * core entry point to probe connector state is @fill_modes.
  371. */
  372. void (*force)(struct drm_connector *connector);
  373. /**
  374. * @fill_modes:
  375. *
  376. * Entry point for output detection and basic mode validation. The
  377. * driver should reprobe the output if needed (e.g. when hotplug
  378. * handling is unreliable), add all detected modes to &drm_connector.modes
  379. * and filter out any the device can't support in any configuration. It
  380. * also needs to filter out any modes wider or higher than the
  381. * parameters max_width and max_height indicate.
  382. *
  383. * The drivers must also prune any modes no longer valid from
  384. * &drm_connector.modes. Furthermore it must update
  385. * &drm_connector.status and &drm_connector.edid. If no EDID has been
  386. * received for this output connector->edid must be NULL.
  387. *
  388. * Drivers using the probe helpers should use
  389. * drm_helper_probe_single_connector_modes() or
  390. * drm_helper_probe_single_connector_modes_nomerge() to implement this
  391. * function.
  392. *
  393. * RETURNS:
  394. *
  395. * The number of modes detected and filled into &drm_connector.modes.
  396. */
  397. int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
  398. /**
  399. * @set_property:
  400. *
  401. * This is the legacy entry point to update a property attached to the
  402. * connector.
  403. *
  404. * Drivers implementing atomic modeset should use
  405. * drm_atomic_helper_connector_set_property() to implement this hook.
  406. *
  407. * This callback is optional if the driver does not support any legacy
  408. * driver-private properties.
  409. *
  410. * RETURNS:
  411. *
  412. * 0 on success or a negative error code on failure.
  413. */
  414. int (*set_property)(struct drm_connector *connector, struct drm_property *property,
  415. uint64_t val);
  416. /**
  417. * @late_register:
  418. *
  419. * This optional hook can be used to register additional userspace
  420. * interfaces attached to the connector, light backlight control, i2c,
  421. * DP aux or similar interfaces. It is called late in the driver load
  422. * sequence from drm_connector_register() when registering all the
  423. * core drm connector interfaces. Everything added from this callback
  424. * should be unregistered in the early_unregister callback.
  425. *
  426. * This is called while holding &drm_connector.mutex.
  427. *
  428. * Returns:
  429. *
  430. * 0 on success, or a negative error code on failure.
  431. */
  432. int (*late_register)(struct drm_connector *connector);
  433. /**
  434. * @early_unregister:
  435. *
  436. * This optional hook should be used to unregister the additional
  437. * userspace interfaces attached to the connector from
  438. * late_register(). It is called from drm_connector_unregister(),
  439. * early in the driver unload sequence to disable userspace access
  440. * before data structures are torndown.
  441. *
  442. * This is called while holding &drm_connector.mutex.
  443. */
  444. void (*early_unregister)(struct drm_connector *connector);
  445. /**
  446. * @destroy:
  447. *
  448. * Clean up connector resources. This is called at driver unload time
  449. * through drm_mode_config_cleanup(). It can also be called at runtime
  450. * when a connector is being hot-unplugged for drivers that support
  451. * connector hotplugging (e.g. DisplayPort MST).
  452. */
  453. void (*destroy)(struct drm_connector *connector);
  454. /**
  455. * @atomic_duplicate_state:
  456. *
  457. * Duplicate the current atomic state for this connector and return it.
  458. * The core and helpers guarantee that any atomic state duplicated with
  459. * this hook and still owned by the caller (i.e. not transferred to the
  460. * driver by calling &drm_mode_config_funcs.atomic_commit) will be
  461. * cleaned up by calling the @atomic_destroy_state hook in this
  462. * structure.
  463. *
  464. * Atomic drivers which don't subclass &struct drm_connector_state should use
  465. * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
  466. * state structure to extend it with driver-private state should use
  467. * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
  468. * duplicated in a consistent fashion across drivers.
  469. *
  470. * It is an error to call this hook before &drm_connector.state has been
  471. * initialized correctly.
  472. *
  473. * NOTE:
  474. *
  475. * If the duplicate state references refcounted resources this hook must
  476. * acquire a reference for each of them. The driver must release these
  477. * references again in @atomic_destroy_state.
  478. *
  479. * RETURNS:
  480. *
  481. * Duplicated atomic state or NULL when the allocation failed.
  482. */
  483. struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
  484. /**
  485. * @atomic_destroy_state:
  486. *
  487. * Destroy a state duplicated with @atomic_duplicate_state and release
  488. * or unreference all resources it references
  489. */
  490. void (*atomic_destroy_state)(struct drm_connector *connector,
  491. struct drm_connector_state *state);
  492. /**
  493. * @atomic_set_property:
  494. *
  495. * Decode a driver-private property value and store the decoded value
  496. * into the passed-in state structure. Since the atomic core decodes all
  497. * standardized properties (even for extensions beyond the core set of
  498. * properties which might not be implemented by all drivers) this
  499. * requires drivers to subclass the state structure.
  500. *
  501. * Such driver-private properties should really only be implemented for
  502. * truly hardware/vendor specific state. Instead it is preferred to
  503. * standardize atomic extension and decode the properties used to expose
  504. * such an extension in the core.
  505. *
  506. * Do not call this function directly, use
  507. * drm_atomic_connector_set_property() instead.
  508. *
  509. * This callback is optional if the driver does not support any
  510. * driver-private atomic properties.
  511. *
  512. * NOTE:
  513. *
  514. * This function is called in the state assembly phase of atomic
  515. * modesets, which can be aborted for any reason (including on
  516. * userspace's request to just check whether a configuration would be
  517. * possible). Drivers MUST NOT touch any persistent state (hardware or
  518. * software) or data structures except the passed in @state parameter.
  519. *
  520. * Also since userspace controls in which order properties are set this
  521. * function must not do any input validation (since the state update is
  522. * incomplete and hence likely inconsistent). Instead any such input
  523. * validation must be done in the various atomic_check callbacks.
  524. *
  525. * RETURNS:
  526. *
  527. * 0 if the property has been found, -EINVAL if the property isn't
  528. * implemented by the driver (which shouldn't ever happen, the core only
  529. * asks for properties attached to this connector). No other validation
  530. * is allowed by the driver. The core already checks that the property
  531. * value is within the range (integer, valid enum value, ...) the driver
  532. * set when registering the property.
  533. */
  534. int (*atomic_set_property)(struct drm_connector *connector,
  535. struct drm_connector_state *state,
  536. struct drm_property *property,
  537. uint64_t val);
  538. /**
  539. * @atomic_get_property:
  540. *
  541. * Reads out the decoded driver-private property. This is used to
  542. * implement the GETCONNECTOR IOCTL.
  543. *
  544. * Do not call this function directly, use
  545. * drm_atomic_connector_get_property() instead.
  546. *
  547. * This callback is optional if the driver does not support any
  548. * driver-private atomic properties.
  549. *
  550. * RETURNS:
  551. *
  552. * 0 on success, -EINVAL if the property isn't implemented by the
  553. * driver (which shouldn't ever happen, the core only asks for
  554. * properties attached to this connector).
  555. */
  556. int (*atomic_get_property)(struct drm_connector *connector,
  557. const struct drm_connector_state *state,
  558. struct drm_property *property,
  559. uint64_t *val);
  560. /**
  561. * @atomic_print_state:
  562. *
  563. * If driver subclasses &struct drm_connector_state, it should implement
  564. * this optional hook for printing additional driver specific state.
  565. *
  566. * Do not call this directly, use drm_atomic_connector_print_state()
  567. * instead.
  568. */
  569. void (*atomic_print_state)(struct drm_printer *p,
  570. const struct drm_connector_state *state);
  571. };
  572. /* mode specified on the command line */
  573. struct drm_cmdline_mode {
  574. bool specified;
  575. bool refresh_specified;
  576. bool bpp_specified;
  577. int xres, yres;
  578. int bpp;
  579. int refresh;
  580. bool rb;
  581. bool interlace;
  582. bool cvt;
  583. bool margins;
  584. enum drm_connector_force force;
  585. };
  586. /**
  587. * struct drm_connector - central DRM connector control structure
  588. * @dev: parent DRM device
  589. * @kdev: kernel device for sysfs attributes
  590. * @attr: sysfs attributes
  591. * @head: list management
  592. * @base: base KMS object
  593. * @name: human readable name, can be overwritten by the driver
  594. * @connector_type: one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
  595. * @connector_type_id: index into connector type enum
  596. * @interlace_allowed: can this connector handle interlaced modes?
  597. * @doublescan_allowed: can this connector handle doublescan?
  598. * @stereo_allowed: can this connector handle stereo modes?
  599. * @funcs: connector control functions
  600. * @edid_blob_ptr: DRM property containing EDID if present
  601. * @properties: property tracking for this connector
  602. * @dpms: current dpms state
  603. * @helper_private: mid-layer private data
  604. * @cmdline_mode: mode line parsed from the kernel cmdline for this connector
  605. * @force: a DRM_FORCE_<foo> state for forced mode sets
  606. * @override_edid: has the EDID been overwritten through debugfs for testing?
  607. * @encoder_ids: valid encoders for this connector
  608. * @encoder: encoder driving this connector, if any
  609. * @eld: EDID-like data, if present
  610. * @latency_present: AV delay info from ELD, if found
  611. * @video_latency: video latency info from ELD, if found
  612. * @audio_latency: audio latency info from ELD, if found
  613. * @null_edid_counter: track sinks that give us all zeros for the EDID
  614. * @bad_edid_counter: track sinks that give us an EDID with invalid checksum
  615. * @edid_corrupt: indicates whether the last read EDID was corrupt
  616. * @debugfs_entry: debugfs directory for this connector
  617. * @has_tile: is this connector connected to a tiled monitor
  618. * @tile_group: tile group for the connected monitor
  619. * @tile_is_single_monitor: whether the tile is one monitor housing
  620. * @num_h_tile: number of horizontal tiles in the tile group
  621. * @num_v_tile: number of vertical tiles in the tile group
  622. * @tile_h_loc: horizontal location of this tile
  623. * @tile_v_loc: vertical location of this tile
  624. * @tile_h_size: horizontal size of this tile.
  625. * @tile_v_size: vertical size of this tile.
  626. *
  627. * Each connector may be connected to one or more CRTCs, or may be clonable by
  628. * another connector if they can share a CRTC. Each connector also has a specific
  629. * position in the broader display (referred to as a 'screen' though it could
  630. * span multiple monitors).
  631. */
  632. struct drm_connector {
  633. struct drm_device *dev;
  634. struct device *kdev;
  635. struct device_attribute *attr;
  636. struct list_head head;
  637. struct drm_mode_object base;
  638. char *name;
  639. /**
  640. * @mutex: Lock for general connector state, but currently only protects
  641. * @registered. Most of the connector state is still protected by
  642. * &drm_mode_config.mutex.
  643. */
  644. struct mutex mutex;
  645. /**
  646. * @index: Compacted connector index, which matches the position inside
  647. * the mode_config.list for drivers not supporting hot-add/removing. Can
  648. * be used as an array index. It is invariant over the lifetime of the
  649. * connector.
  650. */
  651. unsigned index;
  652. int connector_type;
  653. int connector_type_id;
  654. bool interlace_allowed;
  655. bool doublescan_allowed;
  656. bool stereo_allowed;
  657. /**
  658. * @registered: Is this connector exposed (registered) with userspace?
  659. * Protected by @mutex.
  660. */
  661. bool registered;
  662. /**
  663. * @modes:
  664. * Modes available on this connector (from fill_modes() + user).
  665. * Protected by &drm_mode_config.mutex.
  666. */
  667. struct list_head modes;
  668. /**
  669. * @status:
  670. * One of the drm_connector_status enums (connected, not, or unknown).
  671. * Protected by &drm_mode_config.mutex.
  672. */
  673. enum drm_connector_status status;
  674. /**
  675. * @probed_modes:
  676. * These are modes added by probing with DDC or the BIOS, before
  677. * filtering is applied. Used by the probe helpers. Protected by
  678. * &drm_mode_config.mutex.
  679. */
  680. struct list_head probed_modes;
  681. /**
  682. * @display_info: Display information is filled from EDID information
  683. * when a display is detected. For non hot-pluggable displays such as
  684. * flat panels in embedded systems, the driver should initialize the
  685. * &drm_display_info.width_mm and &drm_display_info.height_mm fields
  686. * with the physical size of the display.
  687. *
  688. * Protected by &drm_mode_config.mutex.
  689. */
  690. struct drm_display_info display_info;
  691. const struct drm_connector_funcs *funcs;
  692. struct drm_property_blob *edid_blob_ptr;
  693. struct drm_object_properties properties;
  694. /**
  695. * @path_blob_ptr:
  696. *
  697. * DRM blob property data for the DP MST path property.
  698. */
  699. struct drm_property_blob *path_blob_ptr;
  700. /**
  701. * @tile_blob_ptr:
  702. *
  703. * DRM blob property data for the tile property (used mostly by DP MST).
  704. * This is meant for screens which are driven through separate display
  705. * pipelines represented by &drm_crtc, which might not be running with
  706. * genlocked clocks. For tiled panels which are genlocked, like
  707. * dual-link LVDS or dual-link DSI, the driver should try to not expose
  708. * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
  709. */
  710. struct drm_property_blob *tile_blob_ptr;
  711. /* should we poll this connector for connects and disconnects */
  712. /* hot plug detectable */
  713. #define DRM_CONNECTOR_POLL_HPD (1 << 0)
  714. /* poll for connections */
  715. #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
  716. /* can cleanly poll for disconnections without flickering the screen */
  717. /* DACs should rarely do this without a lot of testing */
  718. #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
  719. /**
  720. * @polled:
  721. *
  722. * Connector polling mode, a combination of
  723. *
  724. * DRM_CONNECTOR_POLL_HPD
  725. * The connector generates hotplug events and doesn't need to be
  726. * periodically polled. The CONNECT and DISCONNECT flags must not
  727. * be set together with the HPD flag.
  728. *
  729. * DRM_CONNECTOR_POLL_CONNECT
  730. * Periodically poll the connector for connection.
  731. *
  732. * DRM_CONNECTOR_POLL_DISCONNECT
  733. * Periodically poll the connector for disconnection.
  734. *
  735. * Set to 0 for connectors that don't support connection status
  736. * discovery.
  737. */
  738. uint8_t polled;
  739. /* requested DPMS state */
  740. int dpms;
  741. const struct drm_connector_helper_funcs *helper_private;
  742. /* forced on connector */
  743. struct drm_cmdline_mode cmdline_mode;
  744. enum drm_connector_force force;
  745. bool override_edid;
  746. #define DRM_CONNECTOR_MAX_ENCODER 3
  747. uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
  748. struct drm_encoder *encoder; /* currently active encoder */
  749. #define MAX_ELD_BYTES 128
  750. /* EDID bits */
  751. uint8_t eld[MAX_ELD_BYTES];
  752. bool latency_present[2];
  753. int video_latency[2]; /* [0]: progressive, [1]: interlaced */
  754. int audio_latency[2];
  755. int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
  756. unsigned bad_edid_counter;
  757. /* Flag for raw EDID header corruption - used in Displayport
  758. * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6
  759. */
  760. bool edid_corrupt;
  761. struct dentry *debugfs_entry;
  762. /**
  763. * @state:
  764. *
  765. * Current atomic state for this connector.
  766. *
  767. * This is protected by @drm_mode_config.connection_mutex. Note that
  768. * nonblocking atomic commits access the current connector state without
  769. * taking locks. Either by going through the &struct drm_atomic_state
  770. * pointers, see for_each_connector_in_state(),
  771. * for_each_oldnew_connector_in_state(),
  772. * for_each_old_connector_in_state() and
  773. * for_each_new_connector_in_state(). Or through careful ordering of
  774. * atomic commit operations as implemented in the atomic helpers, see
  775. * &struct drm_crtc_commit.
  776. */
  777. struct drm_connector_state *state;
  778. /* DisplayID bits */
  779. bool has_tile;
  780. struct drm_tile_group *tile_group;
  781. bool tile_is_single_monitor;
  782. uint8_t num_h_tile, num_v_tile;
  783. uint8_t tile_h_loc, tile_v_loc;
  784. uint16_t tile_h_size, tile_v_size;
  785. };
  786. #define obj_to_connector(x) container_of(x, struct drm_connector, base)
  787. int drm_connector_init(struct drm_device *dev,
  788. struct drm_connector *connector,
  789. const struct drm_connector_funcs *funcs,
  790. int connector_type);
  791. int drm_connector_register(struct drm_connector *connector);
  792. void drm_connector_unregister(struct drm_connector *connector);
  793. int drm_mode_connector_attach_encoder(struct drm_connector *connector,
  794. struct drm_encoder *encoder);
  795. void drm_connector_cleanup(struct drm_connector *connector);
  796. static inline unsigned drm_connector_index(struct drm_connector *connector)
  797. {
  798. return connector->index;
  799. }
  800. /**
  801. * drm_connector_lookup - lookup connector object
  802. * @dev: DRM device
  803. * @id: connector object id
  804. *
  805. * This function looks up the connector object specified by id
  806. * add takes a reference to it.
  807. */
  808. static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
  809. uint32_t id)
  810. {
  811. struct drm_mode_object *mo;
  812. mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR);
  813. return mo ? obj_to_connector(mo) : NULL;
  814. }
  815. /**
  816. * drm_connector_get - acquire a connector reference
  817. * @connector: DRM connector
  818. *
  819. * This function increments the connector's refcount.
  820. */
  821. static inline void drm_connector_get(struct drm_connector *connector)
  822. {
  823. drm_mode_object_get(&connector->base);
  824. }
  825. /**
  826. * drm_connector_put - release a connector reference
  827. * @connector: DRM connector
  828. *
  829. * This function decrements the connector's reference count and frees the
  830. * object if the reference count drops to zero.
  831. */
  832. static inline void drm_connector_put(struct drm_connector *connector)
  833. {
  834. drm_mode_object_put(&connector->base);
  835. }
  836. /**
  837. * drm_connector_reference - acquire a connector reference
  838. * @connector: DRM connector
  839. *
  840. * This is a compatibility alias for drm_connector_get() and should not be
  841. * used by new code.
  842. */
  843. static inline void drm_connector_reference(struct drm_connector *connector)
  844. {
  845. drm_connector_get(connector);
  846. }
  847. /**
  848. * drm_connector_unreference - release a connector reference
  849. * @connector: DRM connector
  850. *
  851. * This is a compatibility alias for drm_connector_put() and should not be
  852. * used by new code.
  853. */
  854. static inline void drm_connector_unreference(struct drm_connector *connector)
  855. {
  856. drm_connector_put(connector);
  857. }
  858. const char *drm_get_connector_status_name(enum drm_connector_status status);
  859. const char *drm_get_subpixel_order_name(enum subpixel_order order);
  860. const char *drm_get_dpms_name(int val);
  861. const char *drm_get_dvi_i_subconnector_name(int val);
  862. const char *drm_get_dvi_i_select_name(int val);
  863. const char *drm_get_tv_subconnector_name(int val);
  864. const char *drm_get_tv_select_name(int val);
  865. int drm_mode_create_dvi_i_properties(struct drm_device *dev);
  866. int drm_mode_create_tv_properties(struct drm_device *dev,
  867. unsigned int num_modes,
  868. const char * const modes[]);
  869. int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  870. int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
  871. int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
  872. int drm_mode_connector_set_path_property(struct drm_connector *connector,
  873. const char *path);
  874. int drm_mode_connector_set_tile_property(struct drm_connector *connector);
  875. int drm_mode_connector_update_edid_property(struct drm_connector *connector,
  876. const struct edid *edid);
  877. void drm_mode_connector_set_link_status_property(struct drm_connector *connector,
  878. uint64_t link_status);
  879. /**
  880. * struct drm_tile_group - Tile group metadata
  881. * @refcount: reference count
  882. * @dev: DRM device
  883. * @id: tile group id exposed to userspace
  884. * @group_data: Sink-private data identifying this group
  885. *
  886. * @group_data corresponds to displayid vend/prod/serial for external screens
  887. * with an EDID.
  888. */
  889. struct drm_tile_group {
  890. struct kref refcount;
  891. struct drm_device *dev;
  892. int id;
  893. u8 group_data[8];
  894. };
  895. struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
  896. char topology[8]);
  897. struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
  898. char topology[8]);
  899. void drm_mode_put_tile_group(struct drm_device *dev,
  900. struct drm_tile_group *tg);
  901. /**
  902. * drm_for_each_connector - iterate over all connectors
  903. * @connector: the loop cursor
  904. * @dev: the DRM device
  905. *
  906. * Iterate over all connectors of @dev.
  907. *
  908. * WARNING:
  909. *
  910. * This iterator is not safe against hotadd/removal of connectors and is
  911. * deprecated. Use drm_for_each_connector_iter() instead.
  912. */
  913. #define drm_for_each_connector(connector, dev) \
  914. list_for_each_entry(connector, &(dev)->mode_config.connector_list, head)
  915. /**
  916. * struct drm_connector_list_iter - connector_list iterator
  917. *
  918. * This iterator tracks state needed to be able to walk the connector_list
  919. * within struct drm_mode_config. Only use together with
  920. * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and
  921. * drm_connector_list_iter_next() respectively the convenience macro
  922. * drm_for_each_connector_iter().
  923. */
  924. struct drm_connector_list_iter {
  925. /* private: */
  926. struct drm_device *dev;
  927. struct drm_connector *conn;
  928. };
  929. void drm_connector_list_iter_begin(struct drm_device *dev,
  930. struct drm_connector_list_iter *iter);
  931. struct drm_connector *
  932. drm_connector_list_iter_next(struct drm_connector_list_iter *iter);
  933. void drm_connector_list_iter_end(struct drm_connector_list_iter *iter);
  934. /**
  935. * drm_for_each_connector_iter - connector_list iterator macro
  936. * @connector: &struct drm_connector pointer used as cursor
  937. * @iter: &struct drm_connector_list_iter
  938. *
  939. * Note that @connector is only valid within the list body, if you want to use
  940. * @connector after calling drm_connector_list_iter_end() then you need to grab
  941. * your own reference first using drm_connector_begin().
  942. */
  943. #define drm_for_each_connector_iter(connector, iter) \
  944. while ((connector = drm_connector_list_iter_next(iter)))
  945. #endif