drm_connector.h 35 KB

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