drm_connector.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  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/llist.h>
  26. #include <linux/ctype.h>
  27. #include <linux/hdmi.h>
  28. #include <drm/drm_mode_object.h>
  29. #include <uapi/drm/drm_mode.h>
  30. struct drm_connector_helper_funcs;
  31. struct drm_modeset_acquire_ctx;
  32. struct drm_device;
  33. struct drm_crtc;
  34. struct drm_encoder;
  35. struct drm_property;
  36. struct drm_property_blob;
  37. struct drm_printer;
  38. struct edid;
  39. enum drm_connector_force {
  40. DRM_FORCE_UNSPECIFIED,
  41. DRM_FORCE_OFF,
  42. DRM_FORCE_ON, /* force on analog part normally */
  43. DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
  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 drm_connector_registration_status - userspace registration status for
  79. * a &drm_connector
  80. *
  81. * This enum is used to track the status of initializing a connector and
  82. * registering it with userspace, so that DRM can prevent bogus modesets on
  83. * connectors that no longer exist.
  84. */
  85. enum drm_connector_registration_state {
  86. /**
  87. * @DRM_CONNECTOR_INITIALIZING: The connector has just been created,
  88. * but has yet to be exposed to userspace. There should be no
  89. * additional restrictions to how the state of this connector may be
  90. * modified.
  91. */
  92. DRM_CONNECTOR_INITIALIZING = 0,
  93. /**
  94. * @DRM_CONNECTOR_REGISTERED: The connector has been fully initialized
  95. * and registered with sysfs, as such it has been exposed to
  96. * userspace. There should be no additional restrictions to how the
  97. * state of this connector may be modified.
  98. */
  99. DRM_CONNECTOR_REGISTERED = 1,
  100. /**
  101. * @DRM_CONNECTOR_UNREGISTERED: The connector has either been exposed
  102. * to userspace and has since been unregistered and removed from
  103. * userspace, or the connector was unregistered before it had a chance
  104. * to be exposed to userspace (e.g. still in the
  105. * @DRM_CONNECTOR_INITIALIZING state). When a connector is
  106. * unregistered, there are additional restrictions to how its state
  107. * may be modified:
  108. *
  109. * - An unregistered connector may only have its DPMS changed from
  110. * On->Off. Once DPMS is changed to Off, it may not be switched back
  111. * to On.
  112. * - Modesets are not allowed on unregistered connectors, unless they
  113. * would result in disabling its assigned CRTCs. This means
  114. * disabling a CRTC on an unregistered connector is OK, but enabling
  115. * one is not.
  116. * - Removing a CRTC from an unregistered connector is OK, but new
  117. * CRTCs may never be assigned to an unregistered connector.
  118. */
  119. DRM_CONNECTOR_UNREGISTERED = 2,
  120. };
  121. enum subpixel_order {
  122. SubPixelUnknown = 0,
  123. SubPixelHorizontalRGB,
  124. SubPixelHorizontalBGR,
  125. SubPixelVerticalRGB,
  126. SubPixelVerticalBGR,
  127. SubPixelNone,
  128. };
  129. /**
  130. * struct drm_scrambling: sink's scrambling support.
  131. */
  132. struct drm_scrambling {
  133. /**
  134. * @supported: scrambling supported for rates > 340 Mhz.
  135. */
  136. bool supported;
  137. /**
  138. * @low_rates: scrambling supported for rates <= 340 Mhz.
  139. */
  140. bool low_rates;
  141. };
  142. /*
  143. * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
  144. *
  145. * Provides SCDC register support and capabilities related information on a
  146. * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
  147. */
  148. struct drm_scdc {
  149. /**
  150. * @supported: status control & data channel present.
  151. */
  152. bool supported;
  153. /**
  154. * @read_request: sink is capable of generating scdc read request.
  155. */
  156. bool read_request;
  157. /**
  158. * @scrambling: sink's scrambling capabilities
  159. */
  160. struct drm_scrambling scrambling;
  161. };
  162. /**
  163. * struct drm_hdmi_info - runtime information about the connected HDMI sink
  164. *
  165. * Describes if a given display supports advanced HDMI 2.0 features.
  166. * This information is available in CEA-861-F extension blocks (like HF-VSDB).
  167. */
  168. struct drm_hdmi_info {
  169. /** @scdc: sink's scdc support and capabilities */
  170. struct drm_scdc scdc;
  171. /**
  172. * @y420_vdb_modes: bitmap of modes which can support ycbcr420
  173. * output only (not normal RGB/YCBCR444/422 outputs). There are total
  174. * 107 VICs defined by CEA-861-F spec, so the size is 128 bits to map
  175. * upto 128 VICs;
  176. */
  177. unsigned long y420_vdb_modes[BITS_TO_LONGS(128)];
  178. /**
  179. * @y420_cmdb_modes: bitmap of modes which can support ycbcr420
  180. * output also, along with normal HDMI outputs. There are total 107
  181. * VICs defined by CEA-861-F spec, so the size is 128 bits to map upto
  182. * 128 VICs;
  183. */
  184. unsigned long y420_cmdb_modes[BITS_TO_LONGS(128)];
  185. /** @y420_cmdb_map: bitmap of SVD index, to extraxt vcb modes */
  186. u64 y420_cmdb_map;
  187. /** @y420_dc_modes: bitmap of deep color support index */
  188. u8 y420_dc_modes;
  189. };
  190. /**
  191. * enum drm_link_status - connector's link_status property value
  192. *
  193. * This enum is used as the connector's link status property value.
  194. * It is set to the values defined in uapi.
  195. *
  196. * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful
  197. * link training
  198. * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training
  199. * failure
  200. */
  201. enum drm_link_status {
  202. DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
  203. DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
  204. };
  205. /**
  206. * enum drm_panel_orientation - panel_orientation info for &drm_display_info
  207. *
  208. * This enum is used to track the (LCD) panel orientation. There are no
  209. * separate #defines for the uapi!
  210. *
  211. * @DRM_MODE_PANEL_ORIENTATION_UNKNOWN: The drm driver has not provided any
  212. * panel orientation information (normal
  213. * for non panels) in this case the "panel
  214. * orientation" connector prop will not be
  215. * attached.
  216. * @DRM_MODE_PANEL_ORIENTATION_NORMAL: The top side of the panel matches the
  217. * top side of the device's casing.
  218. * @DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP: The top side of the panel matches the
  219. * bottom side of the device's casing, iow
  220. * the panel is mounted upside-down.
  221. * @DRM_MODE_PANEL_ORIENTATION_LEFT_UP: The left side of the panel matches the
  222. * top side of the device's casing.
  223. * @DRM_MODE_PANEL_ORIENTATION_RIGHT_UP: The right side of the panel matches the
  224. * top side of the device's casing.
  225. */
  226. enum drm_panel_orientation {
  227. DRM_MODE_PANEL_ORIENTATION_UNKNOWN = -1,
  228. DRM_MODE_PANEL_ORIENTATION_NORMAL = 0,
  229. DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP,
  230. DRM_MODE_PANEL_ORIENTATION_LEFT_UP,
  231. DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
  232. };
  233. /**
  234. * struct drm_display_info - runtime data about the connected sink
  235. *
  236. * Describes a given display (e.g. CRT or flat panel) and its limitations. For
  237. * fixed display sinks like built-in panels there's not much difference between
  238. * this and &struct drm_connector. But for sinks with a real cable this
  239. * structure is meant to describe all the things at the other end of the cable.
  240. *
  241. * For sinks which provide an EDID this can be filled out by calling
  242. * drm_add_edid_modes().
  243. */
  244. struct drm_display_info {
  245. /**
  246. * @name: Name of the display.
  247. */
  248. char name[DRM_DISPLAY_INFO_LEN];
  249. /**
  250. * @width_mm: Physical width in mm.
  251. */
  252. unsigned int width_mm;
  253. /**
  254. * @height_mm: Physical height in mm.
  255. */
  256. unsigned int height_mm;
  257. /**
  258. * @pixel_clock: Maximum pixel clock supported by the sink, in units of
  259. * 100Hz. This mismatches the clock in &drm_display_mode (which is in
  260. * kHZ), because that's what the EDID uses as base unit.
  261. */
  262. unsigned int pixel_clock;
  263. /**
  264. * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
  265. */
  266. unsigned int bpc;
  267. /**
  268. * @subpixel_order: Subpixel order of LCD panels.
  269. */
  270. enum subpixel_order subpixel_order;
  271. #define DRM_COLOR_FORMAT_RGB444 (1<<0)
  272. #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
  273. #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
  274. #define DRM_COLOR_FORMAT_YCRCB420 (1<<3)
  275. /**
  276. * @panel_orientation: Read only connector property for built-in panels,
  277. * indicating the orientation of the panel vs the device's casing.
  278. * drm_connector_init() sets this to DRM_MODE_PANEL_ORIENTATION_UNKNOWN.
  279. * When not UNKNOWN this gets used by the drm_fb_helpers to rotate the
  280. * fb to compensate and gets exported as prop to userspace.
  281. */
  282. int panel_orientation;
  283. /**
  284. * @color_formats: HDMI Color formats, selects between RGB and YCrCb
  285. * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones
  286. * as used to describe the pixel format in framebuffers, and also don't
  287. * match the formats in @bus_formats which are shared with v4l.
  288. */
  289. u32 color_formats;
  290. /**
  291. * @bus_formats: Pixel data format on the wire, somewhat redundant with
  292. * @color_formats. Array of size @num_bus_formats encoded using
  293. * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
  294. */
  295. const u32 *bus_formats;
  296. /**
  297. * @num_bus_formats: Size of @bus_formats array.
  298. */
  299. unsigned int num_bus_formats;
  300. #define DRM_BUS_FLAG_DE_LOW (1<<0)
  301. #define DRM_BUS_FLAG_DE_HIGH (1<<1)
  302. /* drive data on pos. edge */
  303. #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2)
  304. /* drive data on neg. edge */
  305. #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3)
  306. /* data is transmitted MSB to LSB on the bus */
  307. #define DRM_BUS_FLAG_DATA_MSB_TO_LSB (1<<4)
  308. /* data is transmitted LSB to MSB on the bus */
  309. #define DRM_BUS_FLAG_DATA_LSB_TO_MSB (1<<5)
  310. /* drive sync on pos. edge */
  311. #define DRM_BUS_FLAG_SYNC_POSEDGE (1<<6)
  312. /* drive sync on neg. edge */
  313. #define DRM_BUS_FLAG_SYNC_NEGEDGE (1<<7)
  314. /**
  315. * @bus_flags: Additional information (like pixel signal polarity) for
  316. * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines.
  317. */
  318. u32 bus_flags;
  319. /**
  320. * @max_tmds_clock: Maximum TMDS clock rate supported by the
  321. * sink in kHz. 0 means undefined.
  322. */
  323. int max_tmds_clock;
  324. /**
  325. * @dvi_dual: Dual-link DVI sink?
  326. */
  327. bool dvi_dual;
  328. /**
  329. * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
  330. */
  331. bool has_hdmi_infoframe;
  332. /**
  333. * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
  334. * more stuff redundant with @bus_formats.
  335. */
  336. u8 edid_hdmi_dc_modes;
  337. /**
  338. * @cea_rev: CEA revision of the HDMI sink.
  339. */
  340. u8 cea_rev;
  341. /**
  342. * @hdmi: advance features of a HDMI sink.
  343. */
  344. struct drm_hdmi_info hdmi;
  345. /**
  346. * @non_desktop: Non desktop display (HMD).
  347. */
  348. bool non_desktop;
  349. };
  350. int drm_display_info_set_bus_formats(struct drm_display_info *info,
  351. const u32 *formats,
  352. unsigned int num_formats);
  353. /**
  354. * struct drm_tv_connector_state - TV connector related states
  355. * @subconnector: selected subconnector
  356. * @margins: margins
  357. * @margins.left: left margin
  358. * @margins.right: right margin
  359. * @margins.top: top margin
  360. * @margins.bottom: bottom margin
  361. * @mode: TV mode
  362. * @brightness: brightness in percent
  363. * @contrast: contrast in percent
  364. * @flicker_reduction: flicker reduction in percent
  365. * @overscan: overscan in percent
  366. * @saturation: saturation in percent
  367. * @hue: hue in percent
  368. */
  369. struct drm_tv_connector_state {
  370. enum drm_mode_subconnector subconnector;
  371. struct {
  372. unsigned int left;
  373. unsigned int right;
  374. unsigned int top;
  375. unsigned int bottom;
  376. } margins;
  377. unsigned int mode;
  378. unsigned int brightness;
  379. unsigned int contrast;
  380. unsigned int flicker_reduction;
  381. unsigned int overscan;
  382. unsigned int saturation;
  383. unsigned int hue;
  384. };
  385. /**
  386. * struct drm_connector_state - mutable connector state
  387. */
  388. struct drm_connector_state {
  389. /** @connector: backpointer to the connector */
  390. struct drm_connector *connector;
  391. /**
  392. * @crtc: CRTC to connect connector to, NULL if disabled.
  393. *
  394. * Do not change this directly, use drm_atomic_set_crtc_for_connector()
  395. * instead.
  396. */
  397. struct drm_crtc *crtc;
  398. /**
  399. * @best_encoder:
  400. *
  401. * Used by the atomic helpers to select the encoder, through the
  402. * &drm_connector_helper_funcs.atomic_best_encoder or
  403. * &drm_connector_helper_funcs.best_encoder callbacks.
  404. */
  405. struct drm_encoder *best_encoder;
  406. /**
  407. * @link_status: Connector link_status to keep track of whether link is
  408. * GOOD or BAD to notify userspace if retraining is necessary.
  409. */
  410. enum drm_link_status link_status;
  411. /** @state: backpointer to global drm_atomic_state */
  412. struct drm_atomic_state *state;
  413. /**
  414. * @commit: Tracks the pending commit to prevent use-after-free conditions.
  415. *
  416. * Is only set when @crtc is NULL.
  417. */
  418. struct drm_crtc_commit *commit;
  419. /** @tv: TV connector state */
  420. struct drm_tv_connector_state tv;
  421. /**
  422. * @picture_aspect_ratio: Connector property to control the
  423. * HDMI infoframe aspect ratio setting.
  424. *
  425. * The %DRM_MODE_PICTURE_ASPECT_\* values much match the
  426. * values for &enum hdmi_picture_aspect
  427. */
  428. enum hdmi_picture_aspect picture_aspect_ratio;
  429. /**
  430. * @content_type: Connector property to control the
  431. * HDMI infoframe content type setting.
  432. * The %DRM_MODE_CONTENT_TYPE_\* values much
  433. * match the values.
  434. */
  435. unsigned int content_type;
  436. /**
  437. * @scaling_mode: Connector property to control the
  438. * upscaling, mostly used for built-in panels.
  439. */
  440. unsigned int scaling_mode;
  441. /**
  442. * @content_protection: Connector property to request content
  443. * protection. This is most commonly used for HDCP.
  444. */
  445. unsigned int content_protection;
  446. /**
  447. * @writeback_job: Writeback job for writeback connectors
  448. *
  449. * Holds the framebuffer and out-fence for a writeback connector. As
  450. * the writeback completion may be asynchronous to the normal commit
  451. * cycle, the writeback job lifetime is managed separately from the
  452. * normal atomic state by this object.
  453. *
  454. * See also: drm_writeback_queue_job() and
  455. * drm_writeback_signal_completion()
  456. */
  457. struct drm_writeback_job *writeback_job;
  458. };
  459. /**
  460. * struct drm_connector_funcs - control connectors on a given device
  461. *
  462. * Each CRTC may have one or more connectors attached to it. The functions
  463. * below allow the core DRM code to control connectors, enumerate available modes,
  464. * etc.
  465. */
  466. struct drm_connector_funcs {
  467. /**
  468. * @dpms:
  469. *
  470. * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
  471. * is exposed as a standard property on the connector, but diverted to
  472. * this callback in the drm core. Note that atomic drivers don't
  473. * implement the 4 level DPMS support on the connector any more, but
  474. * instead only have an on/off "ACTIVE" property on the CRTC object.
  475. *
  476. * This hook is not used by atomic drivers, remapping of the legacy DPMS
  477. * property is entirely handled in the DRM core.
  478. *
  479. * RETURNS:
  480. *
  481. * 0 on success or a negative error code on failure.
  482. */
  483. int (*dpms)(struct drm_connector *connector, int mode);
  484. /**
  485. * @reset:
  486. *
  487. * Reset connector hardware and software state to off. This function isn't
  488. * called by the core directly, only through drm_mode_config_reset().
  489. * It's not a helper hook only for historical reasons.
  490. *
  491. * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
  492. * atomic state using this hook.
  493. */
  494. void (*reset)(struct drm_connector *connector);
  495. /**
  496. * @detect:
  497. *
  498. * Check to see if anything is attached to the connector. The parameter
  499. * force is set to false whilst polling, true when checking the
  500. * connector due to a user request. force can be used by the driver to
  501. * avoid expensive, destructive operations during automated probing.
  502. *
  503. * This callback is optional, if not implemented the connector will be
  504. * considered as always being attached.
  505. *
  506. * FIXME:
  507. *
  508. * Note that this hook is only called by the probe helper. It's not in
  509. * the helper library vtable purely for historical reasons. The only DRM
  510. * core entry point to probe connector state is @fill_modes.
  511. *
  512. * Note that the helper library will already hold
  513. * &drm_mode_config.connection_mutex. Drivers which need to grab additional
  514. * locks to avoid races with concurrent modeset changes need to use
  515. * &drm_connector_helper_funcs.detect_ctx instead.
  516. *
  517. * RETURNS:
  518. *
  519. * drm_connector_status indicating the connector's status.
  520. */
  521. enum drm_connector_status (*detect)(struct drm_connector *connector,
  522. bool force);
  523. /**
  524. * @force:
  525. *
  526. * This function is called to update internal encoder state when the
  527. * connector is forced to a certain state by userspace, either through
  528. * the sysfs interfaces or on the kernel cmdline. In that case the
  529. * @detect callback isn't called.
  530. *
  531. * FIXME:
  532. *
  533. * Note that this hook is only called by the probe helper. It's not in
  534. * the helper library vtable purely for historical reasons. The only DRM
  535. * core entry point to probe connector state is @fill_modes.
  536. */
  537. void (*force)(struct drm_connector *connector);
  538. /**
  539. * @fill_modes:
  540. *
  541. * Entry point for output detection and basic mode validation. The
  542. * driver should reprobe the output if needed (e.g. when hotplug
  543. * handling is unreliable), add all detected modes to &drm_connector.modes
  544. * and filter out any the device can't support in any configuration. It
  545. * also needs to filter out any modes wider or higher than the
  546. * parameters max_width and max_height indicate.
  547. *
  548. * The drivers must also prune any modes no longer valid from
  549. * &drm_connector.modes. Furthermore it must update
  550. * &drm_connector.status and &drm_connector.edid. If no EDID has been
  551. * received for this output connector->edid must be NULL.
  552. *
  553. * Drivers using the probe helpers should use
  554. * drm_helper_probe_single_connector_modes() to implement this
  555. * function.
  556. *
  557. * RETURNS:
  558. *
  559. * The number of modes detected and filled into &drm_connector.modes.
  560. */
  561. int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
  562. /**
  563. * @set_property:
  564. *
  565. * This is the legacy entry point to update a property attached to the
  566. * connector.
  567. *
  568. * This callback is optional if the driver does not support any legacy
  569. * driver-private properties. For atomic drivers it is not used because
  570. * property handling is done entirely in the DRM core.
  571. *
  572. * RETURNS:
  573. *
  574. * 0 on success or a negative error code on failure.
  575. */
  576. int (*set_property)(struct drm_connector *connector, struct drm_property *property,
  577. uint64_t val);
  578. /**
  579. * @late_register:
  580. *
  581. * This optional hook can be used to register additional userspace
  582. * interfaces attached to the connector, light backlight control, i2c,
  583. * DP aux or similar interfaces. It is called late in the driver load
  584. * sequence from drm_connector_register() when registering all the
  585. * core drm connector interfaces. Everything added from this callback
  586. * should be unregistered in the early_unregister callback.
  587. *
  588. * This is called while holding &drm_connector.mutex.
  589. *
  590. * Returns:
  591. *
  592. * 0 on success, or a negative error code on failure.
  593. */
  594. int (*late_register)(struct drm_connector *connector);
  595. /**
  596. * @early_unregister:
  597. *
  598. * This optional hook should be used to unregister the additional
  599. * userspace interfaces attached to the connector from
  600. * late_register(). It is called from drm_connector_unregister(),
  601. * early in the driver unload sequence to disable userspace access
  602. * before data structures are torndown.
  603. *
  604. * This is called while holding &drm_connector.mutex.
  605. */
  606. void (*early_unregister)(struct drm_connector *connector);
  607. /**
  608. * @destroy:
  609. *
  610. * Clean up connector resources. This is called at driver unload time
  611. * through drm_mode_config_cleanup(). It can also be called at runtime
  612. * when a connector is being hot-unplugged for drivers that support
  613. * connector hotplugging (e.g. DisplayPort MST).
  614. */
  615. void (*destroy)(struct drm_connector *connector);
  616. /**
  617. * @atomic_duplicate_state:
  618. *
  619. * Duplicate the current atomic state for this connector and return it.
  620. * The core and helpers guarantee that any atomic state duplicated with
  621. * this hook and still owned by the caller (i.e. not transferred to the
  622. * driver by calling &drm_mode_config_funcs.atomic_commit) will be
  623. * cleaned up by calling the @atomic_destroy_state hook in this
  624. * structure.
  625. *
  626. * This callback is mandatory for atomic drivers.
  627. *
  628. * Atomic drivers which don't subclass &struct drm_connector_state should use
  629. * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
  630. * state structure to extend it with driver-private state should use
  631. * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
  632. * duplicated in a consistent fashion across drivers.
  633. *
  634. * It is an error to call this hook before &drm_connector.state has been
  635. * initialized correctly.
  636. *
  637. * NOTE:
  638. *
  639. * If the duplicate state references refcounted resources this hook must
  640. * acquire a reference for each of them. The driver must release these
  641. * references again in @atomic_destroy_state.
  642. *
  643. * RETURNS:
  644. *
  645. * Duplicated atomic state or NULL when the allocation failed.
  646. */
  647. struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
  648. /**
  649. * @atomic_destroy_state:
  650. *
  651. * Destroy a state duplicated with @atomic_duplicate_state and release
  652. * or unreference all resources it references
  653. *
  654. * This callback is mandatory for atomic drivers.
  655. */
  656. void (*atomic_destroy_state)(struct drm_connector *connector,
  657. struct drm_connector_state *state);
  658. /**
  659. * @atomic_set_property:
  660. *
  661. * Decode a driver-private property value and store the decoded value
  662. * into the passed-in state structure. Since the atomic core decodes all
  663. * standardized properties (even for extensions beyond the core set of
  664. * properties which might not be implemented by all drivers) this
  665. * requires drivers to subclass the state structure.
  666. *
  667. * Such driver-private properties should really only be implemented for
  668. * truly hardware/vendor specific state. Instead it is preferred to
  669. * standardize atomic extension and decode the properties used to expose
  670. * such an extension in the core.
  671. *
  672. * Do not call this function directly, use
  673. * drm_atomic_connector_set_property() instead.
  674. *
  675. * This callback is optional if the driver does not support any
  676. * driver-private atomic properties.
  677. *
  678. * NOTE:
  679. *
  680. * This function is called in the state assembly phase of atomic
  681. * modesets, which can be aborted for any reason (including on
  682. * userspace's request to just check whether a configuration would be
  683. * possible). Drivers MUST NOT touch any persistent state (hardware or
  684. * software) or data structures except the passed in @state parameter.
  685. *
  686. * Also since userspace controls in which order properties are set this
  687. * function must not do any input validation (since the state update is
  688. * incomplete and hence likely inconsistent). Instead any such input
  689. * validation must be done in the various atomic_check callbacks.
  690. *
  691. * RETURNS:
  692. *
  693. * 0 if the property has been found, -EINVAL if the property isn't
  694. * implemented by the driver (which shouldn't ever happen, the core only
  695. * asks for properties attached to this connector). No other validation
  696. * is allowed by the driver. The core already checks that the property
  697. * value is within the range (integer, valid enum value, ...) the driver
  698. * set when registering the property.
  699. */
  700. int (*atomic_set_property)(struct drm_connector *connector,
  701. struct drm_connector_state *state,
  702. struct drm_property *property,
  703. uint64_t val);
  704. /**
  705. * @atomic_get_property:
  706. *
  707. * Reads out the decoded driver-private property. This is used to
  708. * implement the GETCONNECTOR IOCTL.
  709. *
  710. * Do not call this function directly, use
  711. * drm_atomic_connector_get_property() instead.
  712. *
  713. * This callback is optional if the driver does not support any
  714. * driver-private atomic properties.
  715. *
  716. * RETURNS:
  717. *
  718. * 0 on success, -EINVAL if the property isn't implemented by the
  719. * driver (which shouldn't ever happen, the core only asks for
  720. * properties attached to this connector).
  721. */
  722. int (*atomic_get_property)(struct drm_connector *connector,
  723. const struct drm_connector_state *state,
  724. struct drm_property *property,
  725. uint64_t *val);
  726. /**
  727. * @atomic_print_state:
  728. *
  729. * If driver subclasses &struct drm_connector_state, it should implement
  730. * this optional hook for printing additional driver specific state.
  731. *
  732. * Do not call this directly, use drm_atomic_connector_print_state()
  733. * instead.
  734. */
  735. void (*atomic_print_state)(struct drm_printer *p,
  736. const struct drm_connector_state *state);
  737. };
  738. /* mode specified on the command line */
  739. struct drm_cmdline_mode {
  740. bool specified;
  741. bool refresh_specified;
  742. bool bpp_specified;
  743. int xres, yres;
  744. int bpp;
  745. int refresh;
  746. bool rb;
  747. bool interlace;
  748. bool cvt;
  749. bool margins;
  750. enum drm_connector_force force;
  751. };
  752. /**
  753. * struct drm_connector - central DRM connector control structure
  754. *
  755. * Each connector may be connected to one or more CRTCs, or may be clonable by
  756. * another connector if they can share a CRTC. Each connector also has a specific
  757. * position in the broader display (referred to as a 'screen' though it could
  758. * span multiple monitors).
  759. */
  760. struct drm_connector {
  761. /** @dev: parent DRM device */
  762. struct drm_device *dev;
  763. /** @kdev: kernel device for sysfs attributes */
  764. struct device *kdev;
  765. /** @attr: sysfs attributes */
  766. struct device_attribute *attr;
  767. /**
  768. * @head:
  769. *
  770. * List of all connectors on a @dev, linked from
  771. * &drm_mode_config.connector_list. Protected by
  772. * &drm_mode_config.connector_list_lock, but please only use
  773. * &drm_connector_list_iter to walk this list.
  774. */
  775. struct list_head head;
  776. /** @base: base KMS object */
  777. struct drm_mode_object base;
  778. /** @name: human readable name, can be overwritten by the driver */
  779. char *name;
  780. /**
  781. * @mutex: Lock for general connector state, but currently only protects
  782. * @registered. Most of the connector state is still protected by
  783. * &drm_mode_config.mutex.
  784. */
  785. struct mutex mutex;
  786. /**
  787. * @index: Compacted connector index, which matches the position inside
  788. * the mode_config.list for drivers not supporting hot-add/removing. Can
  789. * be used as an array index. It is invariant over the lifetime of the
  790. * connector.
  791. */
  792. unsigned index;
  793. /**
  794. * @connector_type:
  795. * one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
  796. */
  797. int connector_type;
  798. /** @connector_type_id: index into connector type enum */
  799. int connector_type_id;
  800. /**
  801. * @interlace_allowed:
  802. * Can this connector handle interlaced modes? Only used by
  803. * drm_helper_probe_single_connector_modes() for mode filtering.
  804. */
  805. bool interlace_allowed;
  806. /**
  807. * @doublescan_allowed:
  808. * Can this connector handle doublescan? Only used by
  809. * drm_helper_probe_single_connector_modes() for mode filtering.
  810. */
  811. bool doublescan_allowed;
  812. /**
  813. * @stereo_allowed:
  814. * Can this connector handle stereo modes? Only used by
  815. * drm_helper_probe_single_connector_modes() for mode filtering.
  816. */
  817. bool stereo_allowed;
  818. /**
  819. * @ycbcr_420_allowed : This bool indicates if this connector is
  820. * capable of handling YCBCR 420 output. While parsing the EDID
  821. * blocks, its very helpful to know, if the source is capable of
  822. * handling YCBCR 420 outputs.
  823. */
  824. bool ycbcr_420_allowed;
  825. /**
  826. * @registration_state: Is this connector initializing, exposed
  827. * (registered) with userspace, or unregistered?
  828. *
  829. * Protected by @mutex.
  830. */
  831. enum drm_connector_registration_state registration_state;
  832. /**
  833. * @modes:
  834. * Modes available on this connector (from fill_modes() + user).
  835. * Protected by &drm_mode_config.mutex.
  836. */
  837. struct list_head modes;
  838. /**
  839. * @status:
  840. * One of the drm_connector_status enums (connected, not, or unknown).
  841. * Protected by &drm_mode_config.mutex.
  842. */
  843. enum drm_connector_status status;
  844. /**
  845. * @probed_modes:
  846. * These are modes added by probing with DDC or the BIOS, before
  847. * filtering is applied. Used by the probe helpers. Protected by
  848. * &drm_mode_config.mutex.
  849. */
  850. struct list_head probed_modes;
  851. /**
  852. * @display_info: Display information is filled from EDID information
  853. * when a display is detected. For non hot-pluggable displays such as
  854. * flat panels in embedded systems, the driver should initialize the
  855. * &drm_display_info.width_mm and &drm_display_info.height_mm fields
  856. * with the physical size of the display.
  857. *
  858. * Protected by &drm_mode_config.mutex.
  859. */
  860. struct drm_display_info display_info;
  861. /** @funcs: connector control functions */
  862. const struct drm_connector_funcs *funcs;
  863. /**
  864. * @edid_blob_ptr: DRM property containing EDID if present. Protected by
  865. * &drm_mode_config.mutex. This should be updated only by calling
  866. * drm_connector_update_edid_property().
  867. */
  868. struct drm_property_blob *edid_blob_ptr;
  869. /** @properties: property tracking for this connector */
  870. struct drm_object_properties properties;
  871. /**
  872. * @scaling_mode_property: Optional atomic property to control the
  873. * upscaling. See drm_connector_attach_content_protection_property().
  874. */
  875. struct drm_property *scaling_mode_property;
  876. /**
  877. * @content_protection_property: DRM ENUM property for content
  878. * protection. See drm_connector_attach_content_protection_property().
  879. */
  880. struct drm_property *content_protection_property;
  881. /**
  882. * @path_blob_ptr:
  883. *
  884. * DRM blob property data for the DP MST path property. This should only
  885. * be updated by calling drm_connector_set_path_property().
  886. */
  887. struct drm_property_blob *path_blob_ptr;
  888. #define DRM_CONNECTOR_POLL_HPD (1 << 0)
  889. #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
  890. #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
  891. /**
  892. * @polled:
  893. *
  894. * Connector polling mode, a combination of
  895. *
  896. * DRM_CONNECTOR_POLL_HPD
  897. * The connector generates hotplug events and doesn't need to be
  898. * periodically polled. The CONNECT and DISCONNECT flags must not
  899. * be set together with the HPD flag.
  900. *
  901. * DRM_CONNECTOR_POLL_CONNECT
  902. * Periodically poll the connector for connection.
  903. *
  904. * DRM_CONNECTOR_POLL_DISCONNECT
  905. * Periodically poll the connector for disconnection, without
  906. * causing flickering even when the connector is in use. DACs should
  907. * rarely do this without a lot of testing.
  908. *
  909. * Set to 0 for connectors that don't support connection status
  910. * discovery.
  911. */
  912. uint8_t polled;
  913. /**
  914. * @dpms: Current dpms state. For legacy drivers the
  915. * &drm_connector_funcs.dpms callback must update this. For atomic
  916. * drivers, this is handled by the core atomic code, and drivers must
  917. * only take &drm_crtc_state.active into account.
  918. */
  919. int dpms;
  920. /** @helper_private: mid-layer private data */
  921. const struct drm_connector_helper_funcs *helper_private;
  922. /** @cmdline_mode: mode line parsed from the kernel cmdline for this connector */
  923. struct drm_cmdline_mode cmdline_mode;
  924. /** @force: a DRM_FORCE_<foo> state for forced mode sets */
  925. enum drm_connector_force force;
  926. /** @override_edid: has the EDID been overwritten through debugfs for testing? */
  927. bool override_edid;
  928. #define DRM_CONNECTOR_MAX_ENCODER 3
  929. /**
  930. * @encoder_ids: Valid encoders for this connector. Please only use
  931. * drm_connector_for_each_possible_encoder() to enumerate these.
  932. */
  933. uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
  934. /**
  935. * @encoder: Currently bound encoder driving this connector, if any.
  936. * Only really meaningful for non-atomic drivers. Atomic drivers should
  937. * instead look at &drm_connector_state.best_encoder, and in case they
  938. * need the CRTC driving this output, &drm_connector_state.crtc.
  939. */
  940. struct drm_encoder *encoder;
  941. #define MAX_ELD_BYTES 128
  942. /** @eld: EDID-like data, if present */
  943. uint8_t eld[MAX_ELD_BYTES];
  944. /** @latency_present: AV delay info from ELD, if found */
  945. bool latency_present[2];
  946. /**
  947. * @video_latency: Video latency info from ELD, if found.
  948. * [0]: progressive, [1]: interlaced
  949. */
  950. int video_latency[2];
  951. /**
  952. * @audio_latency: audio latency info from ELD, if found
  953. * [0]: progressive, [1]: interlaced
  954. */
  955. int audio_latency[2];
  956. /**
  957. * @null_edid_counter: track sinks that give us all zeros for the EDID.
  958. * Needed to workaround some HW bugs where we get all 0s
  959. */
  960. int null_edid_counter;
  961. /** @bad_edid_counter: track sinks that give us an EDID with invalid checksum */
  962. unsigned bad_edid_counter;
  963. /**
  964. * @edid_corrupt: Indicates whether the last read EDID was corrupt. Used
  965. * in Displayport compliance testing - Displayport Link CTS Core 1.2
  966. * rev1.1 4.2.2.6
  967. */
  968. bool edid_corrupt;
  969. /** @debugfs_entry: debugfs directory for this connector */
  970. struct dentry *debugfs_entry;
  971. /**
  972. * @state:
  973. *
  974. * Current atomic state for this connector.
  975. *
  976. * This is protected by &drm_mode_config.connection_mutex. Note that
  977. * nonblocking atomic commits access the current connector state without
  978. * taking locks. Either by going through the &struct drm_atomic_state
  979. * pointers, see for_each_oldnew_connector_in_state(),
  980. * for_each_old_connector_in_state() and
  981. * for_each_new_connector_in_state(). Or through careful ordering of
  982. * atomic commit operations as implemented in the atomic helpers, see
  983. * &struct drm_crtc_commit.
  984. */
  985. struct drm_connector_state *state;
  986. /* DisplayID bits. FIXME: Extract into a substruct? */
  987. /**
  988. * @tile_blob_ptr:
  989. *
  990. * DRM blob property data for the tile property (used mostly by DP MST).
  991. * This is meant for screens which are driven through separate display
  992. * pipelines represented by &drm_crtc, which might not be running with
  993. * genlocked clocks. For tiled panels which are genlocked, like
  994. * dual-link LVDS or dual-link DSI, the driver should try to not expose
  995. * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
  996. *
  997. * This should only be updated by calling
  998. * drm_connector_set_tile_property().
  999. */
  1000. struct drm_property_blob *tile_blob_ptr;
  1001. /** @has_tile: is this connector connected to a tiled monitor */
  1002. bool has_tile;
  1003. /** @tile_group: tile group for the connected monitor */
  1004. struct drm_tile_group *tile_group;
  1005. /** @tile_is_single_monitor: whether the tile is one monitor housing */
  1006. bool tile_is_single_monitor;
  1007. /** @num_h_tile: number of horizontal tiles in the tile group */
  1008. /** @num_v_tile: number of vertical tiles in the tile group */
  1009. uint8_t num_h_tile, num_v_tile;
  1010. /** @tile_h_loc: horizontal location of this tile */
  1011. /** @tile_v_loc: vertical location of this tile */
  1012. uint8_t tile_h_loc, tile_v_loc;
  1013. /** @tile_h_size: horizontal size of this tile. */
  1014. /** @tile_v_size: vertical size of this tile. */
  1015. uint16_t tile_h_size, tile_v_size;
  1016. /**
  1017. * @free_node:
  1018. *
  1019. * List used only by &drm_connector_list_iter to be able to clean up a
  1020. * connector from any context, in conjunction with
  1021. * &drm_mode_config.connector_free_work.
  1022. */
  1023. struct llist_node free_node;
  1024. };
  1025. #define obj_to_connector(x) container_of(x, struct drm_connector, base)
  1026. int drm_connector_init(struct drm_device *dev,
  1027. struct drm_connector *connector,
  1028. const struct drm_connector_funcs *funcs,
  1029. int connector_type);
  1030. int drm_connector_register(struct drm_connector *connector);
  1031. void drm_connector_unregister(struct drm_connector *connector);
  1032. int drm_connector_attach_encoder(struct drm_connector *connector,
  1033. struct drm_encoder *encoder);
  1034. void drm_connector_cleanup(struct drm_connector *connector);
  1035. static inline unsigned int drm_connector_index(const struct drm_connector *connector)
  1036. {
  1037. return connector->index;
  1038. }
  1039. static inline u32 drm_connector_mask(const struct drm_connector *connector)
  1040. {
  1041. return 1 << connector->index;
  1042. }
  1043. /**
  1044. * drm_connector_lookup - lookup connector object
  1045. * @dev: DRM device
  1046. * @file_priv: drm file to check for lease against.
  1047. * @id: connector object id
  1048. *
  1049. * This function looks up the connector object specified by id
  1050. * add takes a reference to it.
  1051. */
  1052. static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
  1053. struct drm_file *file_priv,
  1054. uint32_t id)
  1055. {
  1056. struct drm_mode_object *mo;
  1057. mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CONNECTOR);
  1058. return mo ? obj_to_connector(mo) : NULL;
  1059. }
  1060. /**
  1061. * drm_connector_get - acquire a connector reference
  1062. * @connector: DRM connector
  1063. *
  1064. * This function increments the connector's refcount.
  1065. */
  1066. static inline void drm_connector_get(struct drm_connector *connector)
  1067. {
  1068. drm_mode_object_get(&connector->base);
  1069. }
  1070. /**
  1071. * drm_connector_put - release a connector reference
  1072. * @connector: DRM connector
  1073. *
  1074. * This function decrements the connector's reference count and frees the
  1075. * object if the reference count drops to zero.
  1076. */
  1077. static inline void drm_connector_put(struct drm_connector *connector)
  1078. {
  1079. drm_mode_object_put(&connector->base);
  1080. }
  1081. /**
  1082. * drm_connector_reference - acquire a connector reference
  1083. * @connector: DRM connector
  1084. *
  1085. * This is a compatibility alias for drm_connector_get() and should not be
  1086. * used by new code.
  1087. */
  1088. static inline void drm_connector_reference(struct drm_connector *connector)
  1089. {
  1090. drm_connector_get(connector);
  1091. }
  1092. /**
  1093. * drm_connector_unreference - release a connector reference
  1094. * @connector: DRM connector
  1095. *
  1096. * This is a compatibility alias for drm_connector_put() and should not be
  1097. * used by new code.
  1098. */
  1099. static inline void drm_connector_unreference(struct drm_connector *connector)
  1100. {
  1101. drm_connector_put(connector);
  1102. }
  1103. /**
  1104. * drm_connector_is_unregistered - has the connector been unregistered from
  1105. * userspace?
  1106. * @connector: DRM connector
  1107. *
  1108. * Checks whether or not @connector has been unregistered from userspace.
  1109. *
  1110. * Returns:
  1111. * True if the connector was unregistered, false if the connector is
  1112. * registered or has not yet been registered with userspace.
  1113. */
  1114. static inline bool
  1115. drm_connector_is_unregistered(struct drm_connector *connector)
  1116. {
  1117. return READ_ONCE(connector->registration_state) ==
  1118. DRM_CONNECTOR_UNREGISTERED;
  1119. }
  1120. const char *drm_get_connector_status_name(enum drm_connector_status status);
  1121. const char *drm_get_subpixel_order_name(enum subpixel_order order);
  1122. const char *drm_get_dpms_name(int val);
  1123. const char *drm_get_dvi_i_subconnector_name(int val);
  1124. const char *drm_get_dvi_i_select_name(int val);
  1125. const char *drm_get_tv_subconnector_name(int val);
  1126. const char *drm_get_tv_select_name(int val);
  1127. const char *drm_get_content_protection_name(int val);
  1128. int drm_mode_create_dvi_i_properties(struct drm_device *dev);
  1129. int drm_mode_create_tv_properties(struct drm_device *dev,
  1130. unsigned int num_modes,
  1131. const char * const modes[]);
  1132. int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  1133. int drm_connector_attach_content_type_property(struct drm_connector *dev);
  1134. int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
  1135. u32 scaling_mode_mask);
  1136. int drm_connector_attach_content_protection_property(
  1137. struct drm_connector *connector);
  1138. int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
  1139. int drm_mode_create_content_type_property(struct drm_device *dev);
  1140. void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe *frame,
  1141. const struct drm_connector_state *conn_state);
  1142. int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
  1143. int drm_connector_set_path_property(struct drm_connector *connector,
  1144. const char *path);
  1145. int drm_connector_set_tile_property(struct drm_connector *connector);
  1146. int drm_connector_update_edid_property(struct drm_connector *connector,
  1147. const struct edid *edid);
  1148. void drm_connector_set_link_status_property(struct drm_connector *connector,
  1149. uint64_t link_status);
  1150. int drm_connector_init_panel_orientation_property(
  1151. struct drm_connector *connector, int width, int height);
  1152. /**
  1153. * struct drm_tile_group - Tile group metadata
  1154. * @refcount: reference count
  1155. * @dev: DRM device
  1156. * @id: tile group id exposed to userspace
  1157. * @group_data: Sink-private data identifying this group
  1158. *
  1159. * @group_data corresponds to displayid vend/prod/serial for external screens
  1160. * with an EDID.
  1161. */
  1162. struct drm_tile_group {
  1163. struct kref refcount;
  1164. struct drm_device *dev;
  1165. int id;
  1166. u8 group_data[8];
  1167. };
  1168. struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
  1169. char topology[8]);
  1170. struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
  1171. char topology[8]);
  1172. void drm_mode_put_tile_group(struct drm_device *dev,
  1173. struct drm_tile_group *tg);
  1174. /**
  1175. * struct drm_connector_list_iter - connector_list iterator
  1176. *
  1177. * This iterator tracks state needed to be able to walk the connector_list
  1178. * within struct drm_mode_config. Only use together with
  1179. * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and
  1180. * drm_connector_list_iter_next() respectively the convenience macro
  1181. * drm_for_each_connector_iter().
  1182. */
  1183. struct drm_connector_list_iter {
  1184. /* private: */
  1185. struct drm_device *dev;
  1186. struct drm_connector *conn;
  1187. };
  1188. void drm_connector_list_iter_begin(struct drm_device *dev,
  1189. struct drm_connector_list_iter *iter);
  1190. struct drm_connector *
  1191. drm_connector_list_iter_next(struct drm_connector_list_iter *iter);
  1192. void drm_connector_list_iter_end(struct drm_connector_list_iter *iter);
  1193. bool drm_connector_has_possible_encoder(struct drm_connector *connector,
  1194. struct drm_encoder *encoder);
  1195. /**
  1196. * drm_for_each_connector_iter - connector_list iterator macro
  1197. * @connector: &struct drm_connector pointer used as cursor
  1198. * @iter: &struct drm_connector_list_iter
  1199. *
  1200. * Note that @connector is only valid within the list body, if you want to use
  1201. * @connector after calling drm_connector_list_iter_end() then you need to grab
  1202. * your own reference first using drm_connector_get().
  1203. */
  1204. #define drm_for_each_connector_iter(connector, iter) \
  1205. while ((connector = drm_connector_list_iter_next(iter)))
  1206. /**
  1207. * drm_connector_for_each_possible_encoder - iterate connector's possible encoders
  1208. * @connector: &struct drm_connector pointer
  1209. * @encoder: &struct drm_encoder pointer used as cursor
  1210. * @__i: int iteration cursor, for macro-internal use
  1211. */
  1212. #define drm_connector_for_each_possible_encoder(connector, encoder, __i) \
  1213. for ((__i) = 0; (__i) < ARRAY_SIZE((connector)->encoder_ids) && \
  1214. (connector)->encoder_ids[(__i)] != 0; (__i)++) \
  1215. for_each_if((encoder) = \
  1216. drm_encoder_find((connector)->dev, NULL, \
  1217. (connector)->encoder_ids[(__i)])) \
  1218. #endif