drm_connector.h 41 KB

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