drm_connector.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722
  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 <drm/drm_util.h>
  30. #include <uapi/drm/drm_mode.h>
  31. struct drm_connector_helper_funcs;
  32. struct drm_modeset_acquire_ctx;
  33. struct drm_device;
  34. struct drm_crtc;
  35. struct drm_encoder;
  36. struct drm_property;
  37. struct drm_property_blob;
  38. struct drm_printer;
  39. struct edid;
  40. struct i2c_adapter;
  41. enum drm_connector_force {
  42. DRM_FORCE_UNSPECIFIED,
  43. DRM_FORCE_OFF,
  44. DRM_FORCE_ON, /* force on analog part normally */
  45. DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
  46. };
  47. /**
  48. * enum drm_connector_status - status for a &drm_connector
  49. *
  50. * This enum is used to track the connector status. There are no separate
  51. * #defines for the uapi!
  52. */
  53. enum drm_connector_status {
  54. /**
  55. * @connector_status_connected: The connector is definitely connected to
  56. * a sink device, and can be enabled.
  57. */
  58. connector_status_connected = 1,
  59. /**
  60. * @connector_status_disconnected: The connector isn't connected to a
  61. * sink device which can be autodetect. For digital outputs like DP or
  62. * HDMI (which can be realiable probed) this means there's really
  63. * nothing there. It is driver-dependent whether a connector with this
  64. * status can be lit up or not.
  65. */
  66. connector_status_disconnected = 2,
  67. /**
  68. * @connector_status_unknown: The connector's status could not be
  69. * reliably detected. This happens when probing would either cause
  70. * flicker (like load-detection when the connector is in use), or when a
  71. * hardware resource isn't available (like when load-detection needs a
  72. * free CRTC). It should be possible to light up the connector with one
  73. * of the listed fallback modes. For default configuration userspace
  74. * should only try to light up connectors with unknown status when
  75. * there's not connector with @connector_status_connected.
  76. */
  77. connector_status_unknown = 3,
  78. };
  79. /**
  80. * enum drm_connector_registration_status - userspace registration status for
  81. * a &drm_connector
  82. *
  83. * This enum is used to track the status of initializing a connector and
  84. * registering it with userspace, so that DRM can prevent bogus modesets on
  85. * connectors that no longer exist.
  86. */
  87. enum drm_connector_registration_state {
  88. /**
  89. * @DRM_CONNECTOR_INITIALIZING: The connector has just been created,
  90. * but has yet to be exposed to userspace. There should be no
  91. * additional restrictions to how the state of this connector may be
  92. * modified.
  93. */
  94. DRM_CONNECTOR_INITIALIZING = 0,
  95. /**
  96. * @DRM_CONNECTOR_REGISTERED: The connector has been fully initialized
  97. * and registered with sysfs, as such it has been exposed to
  98. * userspace. There should be no additional restrictions to how the
  99. * state of this connector may be modified.
  100. */
  101. DRM_CONNECTOR_REGISTERED = 1,
  102. /**
  103. * @DRM_CONNECTOR_UNREGISTERED: The connector has either been exposed
  104. * to userspace and has since been unregistered and removed from
  105. * userspace, or the connector was unregistered before it had a chance
  106. * to be exposed to userspace (e.g. still in the
  107. * @DRM_CONNECTOR_INITIALIZING state). When a connector is
  108. * unregistered, there are additional restrictions to how its state
  109. * may be modified:
  110. *
  111. * - An unregistered connector may only have its DPMS changed from
  112. * On->Off. Once DPMS is changed to Off, it may not be switched back
  113. * to On.
  114. * - Modesets are not allowed on unregistered connectors, unless they
  115. * would result in disabling its assigned CRTCs. This means
  116. * disabling a CRTC on an unregistered connector is OK, but enabling
  117. * one is not.
  118. * - Removing a CRTC from an unregistered connector is OK, but new
  119. * CRTCs may never be assigned to an unregistered connector.
  120. */
  121. DRM_CONNECTOR_UNREGISTERED = 2,
  122. };
  123. enum subpixel_order {
  124. SubPixelUnknown = 0,
  125. SubPixelHorizontalRGB,
  126. SubPixelHorizontalBGR,
  127. SubPixelVerticalRGB,
  128. SubPixelVerticalBGR,
  129. SubPixelNone,
  130. };
  131. /**
  132. * struct drm_scrambling: sink's scrambling support.
  133. */
  134. struct drm_scrambling {
  135. /**
  136. * @supported: scrambling supported for rates > 340 Mhz.
  137. */
  138. bool supported;
  139. /**
  140. * @low_rates: scrambling supported for rates <= 340 Mhz.
  141. */
  142. bool low_rates;
  143. };
  144. /*
  145. * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
  146. *
  147. * Provides SCDC register support and capabilities related information on a
  148. * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
  149. */
  150. struct drm_scdc {
  151. /**
  152. * @supported: status control & data channel present.
  153. */
  154. bool supported;
  155. /**
  156. * @read_request: sink is capable of generating scdc read request.
  157. */
  158. bool read_request;
  159. /**
  160. * @scrambling: sink's scrambling capabilities
  161. */
  162. struct drm_scrambling scrambling;
  163. };
  164. /**
  165. * struct drm_hdmi_info - runtime information about the connected HDMI sink
  166. *
  167. * Describes if a given display supports advanced HDMI 2.0 features.
  168. * This information is available in CEA-861-F extension blocks (like HF-VSDB).
  169. */
  170. struct drm_hdmi_info {
  171. /** @scdc: sink's scdc support and capabilities */
  172. struct drm_scdc scdc;
  173. /**
  174. * @y420_vdb_modes: bitmap of modes which can support ycbcr420
  175. * output only (not normal RGB/YCBCR444/422 outputs). The max VIC
  176. * defined by the CEA-861-G spec is 219, so the size is 256 bits to map
  177. * up to 256 VICs.
  178. */
  179. unsigned long y420_vdb_modes[BITS_TO_LONGS(256)];
  180. /**
  181. * @y420_cmdb_modes: bitmap of modes which can support ycbcr420
  182. * output also, along with normal HDMI outputs. The max VIC defined by
  183. * the CEA-861-G spec is 219, so the size is 256 bits to map up to 256
  184. * VICs.
  185. */
  186. unsigned long y420_cmdb_modes[BITS_TO_LONGS(256)];
  187. /** @y420_cmdb_map: bitmap of SVD index, to extraxt vcb modes */
  188. u64 y420_cmdb_map;
  189. /** @y420_dc_modes: bitmap of deep color support index */
  190. u8 y420_dc_modes;
  191. };
  192. /**
  193. * enum drm_link_status - connector's link_status property value
  194. *
  195. * This enum is used as the connector's link status property value.
  196. * It is set to the values defined in uapi.
  197. *
  198. * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful
  199. * link training
  200. * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training
  201. * failure
  202. */
  203. enum drm_link_status {
  204. DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
  205. DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
  206. };
  207. /**
  208. * enum drm_panel_orientation - panel_orientation info for &drm_display_info
  209. *
  210. * This enum is used to track the (LCD) panel orientation. There are no
  211. * separate #defines for the uapi!
  212. *
  213. * @DRM_MODE_PANEL_ORIENTATION_UNKNOWN: The drm driver has not provided any
  214. * panel orientation information (normal
  215. * for non panels) in this case the "panel
  216. * orientation" connector prop will not be
  217. * attached.
  218. * @DRM_MODE_PANEL_ORIENTATION_NORMAL: The top side of the panel matches the
  219. * top side of the device's casing.
  220. * @DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP: The top side of the panel matches the
  221. * bottom side of the device's casing, iow
  222. * the panel is mounted upside-down.
  223. * @DRM_MODE_PANEL_ORIENTATION_LEFT_UP: The left side of the panel matches the
  224. * top side of the device's casing.
  225. * @DRM_MODE_PANEL_ORIENTATION_RIGHT_UP: The right side of the panel matches the
  226. * top side of the device's casing.
  227. */
  228. enum drm_panel_orientation {
  229. DRM_MODE_PANEL_ORIENTATION_UNKNOWN = -1,
  230. DRM_MODE_PANEL_ORIENTATION_NORMAL = 0,
  231. DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP,
  232. DRM_MODE_PANEL_ORIENTATION_LEFT_UP,
  233. DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
  234. };
  235. /**
  236. * struct drm_monitor_range_info - Panel's Monitor range in EDID for
  237. * &drm_display_info
  238. *
  239. * This struct is used to store a frequency range supported by panel
  240. * as parsed from EDID's detailed monitor range descriptor block.
  241. *
  242. * @min_vfreq: This is the min supported refresh rate in Hz from
  243. * EDID's detailed monitor range.
  244. * @max_vfreq: This is the max supported refresh rate in Hz from
  245. * EDID's detailed monitor range
  246. */
  247. struct drm_monitor_range_info {
  248. u8 min_vfreq;
  249. u8 max_vfreq;
  250. };
  251. /*
  252. * This is a consolidated colorimetry list supported by HDMI and
  253. * DP protocol standard. The respective connectors will register
  254. * a property with the subset of this list (supported by that
  255. * respective protocol). Userspace will set the colorspace through
  256. * a colorspace property which will be created and exposed to
  257. * userspace.
  258. */
  259. /* For Default case, driver will set the colorspace */
  260. #define DRM_MODE_COLORIMETRY_DEFAULT 0
  261. /* CEA 861 Normal Colorimetry options */
  262. #define DRM_MODE_COLORIMETRY_NO_DATA 0
  263. #define DRM_MODE_COLORIMETRY_SMPTE_170M_YCC 1
  264. #define DRM_MODE_COLORIMETRY_BT709_YCC 2
  265. /* CEA 861 Extended Colorimetry Options */
  266. #define DRM_MODE_COLORIMETRY_XVYCC_601 3
  267. #define DRM_MODE_COLORIMETRY_XVYCC_709 4
  268. #define DRM_MODE_COLORIMETRY_SYCC_601 5
  269. #define DRM_MODE_COLORIMETRY_OPYCC_601 6
  270. #define DRM_MODE_COLORIMETRY_OPRGB 7
  271. #define DRM_MODE_COLORIMETRY_BT2020_CYCC 8
  272. #define DRM_MODE_COLORIMETRY_BT2020_RGB 9
  273. #define DRM_MODE_COLORIMETRY_BT2020_YCC 10
  274. /* Additional Colorimetry extension added as part of CTA 861.G */
  275. #define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65 11
  276. #define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER 12
  277. /* Additional Colorimetry Options added for DP 1.4a VSC Colorimetry Format */
  278. #define DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED 13
  279. #define DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT 14
  280. #define DRM_MODE_COLORIMETRY_BT601_YCC 15
  281. /**
  282. * enum drm_bus_flags - bus_flags info for &drm_display_info
  283. *
  284. * This enum defines signal polarities and clock edge information for signals on
  285. * a bus as bitmask flags.
  286. *
  287. * The clock edge information is conveyed by two sets of symbols,
  288. * DRM_BUS_FLAGS_*_DRIVE_\* and DRM_BUS_FLAGS_*_SAMPLE_\*. When this enum is
  289. * used to describe a bus from the point of view of the transmitter, the
  290. * \*_DRIVE_\* flags should be used. When used from the point of view of the
  291. * receiver, the \*_SAMPLE_\* flags should be used. The \*_DRIVE_\* and
  292. * \*_SAMPLE_\* flags alias each other, with the \*_SAMPLE_POSEDGE and
  293. * \*_SAMPLE_NEGEDGE flags being equal to \*_DRIVE_NEGEDGE and \*_DRIVE_POSEDGE
  294. * respectively. This simplifies code as signals are usually sampled on the
  295. * opposite edge of the driving edge. Transmitters and receivers may however
  296. * need to take other signal timings into account to convert between driving
  297. * and sample edges.
  298. */
  299. enum drm_bus_flags {
  300. /**
  301. * @DRM_BUS_FLAG_DE_LOW:
  302. *
  303. * The Data Enable signal is active low
  304. */
  305. DRM_BUS_FLAG_DE_LOW = BIT(0),
  306. /**
  307. * @DRM_BUS_FLAG_DE_HIGH:
  308. *
  309. * The Data Enable signal is active high
  310. */
  311. DRM_BUS_FLAG_DE_HIGH = BIT(1),
  312. /**
  313. * @DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE:
  314. *
  315. * Data is driven on the rising edge of the pixel clock
  316. */
  317. DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE = BIT(2),
  318. /**
  319. * @DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE:
  320. *
  321. * Data is driven on the falling edge of the pixel clock
  322. */
  323. DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE = BIT(3),
  324. /**
  325. * @DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE:
  326. *
  327. * Data is sampled on the rising edge of the pixel clock
  328. */
  329. DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE,
  330. /**
  331. * @DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE:
  332. *
  333. * Data is sampled on the falling edge of the pixel clock
  334. */
  335. DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,
  336. /**
  337. * @DRM_BUS_FLAG_DATA_MSB_TO_LSB:
  338. *
  339. * Data is transmitted MSB to LSB on the bus
  340. */
  341. DRM_BUS_FLAG_DATA_MSB_TO_LSB = BIT(4),
  342. /**
  343. * @DRM_BUS_FLAG_DATA_LSB_TO_MSB:
  344. *
  345. * Data is transmitted LSB to MSB on the bus
  346. */
  347. DRM_BUS_FLAG_DATA_LSB_TO_MSB = BIT(5),
  348. /**
  349. * @DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE:
  350. *
  351. * Sync signals are driven on the rising edge of the pixel clock
  352. */
  353. DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE = BIT(6),
  354. /**
  355. * @DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE:
  356. *
  357. * Sync signals are driven on the falling edge of the pixel clock
  358. */
  359. DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE = BIT(7),
  360. /**
  361. * @DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE:
  362. *
  363. * Sync signals are sampled on the rising edge of the pixel clock
  364. */
  365. DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE = DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE,
  366. /**
  367. * @DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE:
  368. *
  369. * Sync signals are sampled on the falling edge of the pixel clock
  370. */
  371. DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE = DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE,
  372. /**
  373. * @DRM_BUS_FLAG_SHARP_SIGNALS:
  374. *
  375. * Set if the Sharp-specific signals (SPL, CLS, PS, REV) must be used
  376. */
  377. DRM_BUS_FLAG_SHARP_SIGNALS = BIT(8),
  378. };
  379. /**
  380. * struct drm_display_info - runtime data about the connected sink
  381. *
  382. * Describes a given display (e.g. CRT or flat panel) and its limitations. For
  383. * fixed display sinks like built-in panels there's not much difference between
  384. * this and &struct drm_connector. But for sinks with a real cable this
  385. * structure is meant to describe all the things at the other end of the cable.
  386. *
  387. * For sinks which provide an EDID this can be filled out by calling
  388. * drm_add_edid_modes().
  389. */
  390. struct drm_display_info {
  391. /**
  392. * @width_mm: Physical width in mm.
  393. */
  394. unsigned int width_mm;
  395. /**
  396. * @height_mm: Physical height in mm.
  397. */
  398. unsigned int height_mm;
  399. /**
  400. * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
  401. */
  402. unsigned int bpc;
  403. /**
  404. * @subpixel_order: Subpixel order of LCD panels.
  405. */
  406. enum subpixel_order subpixel_order;
  407. #define DRM_COLOR_FORMAT_RGB444 (1<<0)
  408. #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
  409. #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
  410. #define DRM_COLOR_FORMAT_YCRCB420 (1<<3)
  411. /**
  412. * @panel_orientation: Read only connector property for built-in panels,
  413. * indicating the orientation of the panel vs the device's casing.
  414. * drm_connector_init() sets this to DRM_MODE_PANEL_ORIENTATION_UNKNOWN.
  415. * When not UNKNOWN this gets used by the drm_fb_helpers to rotate the
  416. * fb to compensate and gets exported as prop to userspace.
  417. */
  418. int panel_orientation;
  419. /**
  420. * @color_formats: HDMI Color formats, selects between RGB and YCrCb
  421. * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones
  422. * as used to describe the pixel format in framebuffers, and also don't
  423. * match the formats in @bus_formats which are shared with v4l.
  424. */
  425. u32 color_formats;
  426. /**
  427. * @bus_formats: Pixel data format on the wire, somewhat redundant with
  428. * @color_formats. Array of size @num_bus_formats encoded using
  429. * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
  430. */
  431. const u32 *bus_formats;
  432. /**
  433. * @num_bus_formats: Size of @bus_formats array.
  434. */
  435. unsigned int num_bus_formats;
  436. /**
  437. * @bus_flags: Additional information (like pixel signal polarity) for
  438. * the pixel data on the bus, using &enum drm_bus_flags values
  439. * DRM_BUS_FLAGS\_.
  440. */
  441. u32 bus_flags;
  442. /**
  443. * @max_tmds_clock: Maximum TMDS clock rate supported by the
  444. * sink in kHz. 0 means undefined.
  445. */
  446. int max_tmds_clock;
  447. /**
  448. * @dvi_dual: Dual-link DVI sink?
  449. */
  450. bool dvi_dual;
  451. /**
  452. * @is_hdmi: True if the sink is an HDMI device.
  453. *
  454. * This field shall be used instead of calling
  455. * drm_detect_hdmi_monitor() when possible.
  456. */
  457. bool is_hdmi;
  458. /**
  459. * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
  460. */
  461. bool has_hdmi_infoframe;
  462. /**
  463. * @rgb_quant_range_selectable: Does the sink support selecting
  464. * the RGB quantization range?
  465. */
  466. bool rgb_quant_range_selectable;
  467. /**
  468. * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
  469. * more stuff redundant with @bus_formats.
  470. */
  471. u8 edid_hdmi_dc_modes;
  472. /**
  473. * @cea_rev: CEA revision of the HDMI sink.
  474. */
  475. u8 cea_rev;
  476. /**
  477. * @hdmi: advance features of a HDMI sink.
  478. */
  479. struct drm_hdmi_info hdmi;
  480. /**
  481. * @non_desktop: Non desktop display (HMD).
  482. */
  483. bool non_desktop;
  484. /**
  485. * @monitor_range: Frequency range supported by monitor range descriptor
  486. */
  487. struct drm_monitor_range_info monitor_range;
  488. };
  489. int drm_display_info_set_bus_formats(struct drm_display_info *info,
  490. const u32 *formats,
  491. unsigned int num_formats);
  492. /**
  493. * struct drm_connector_tv_margins - TV connector related margins
  494. *
  495. * Describes the margins in pixels to put around the image on TV
  496. * connectors to deal with overscan.
  497. */
  498. struct drm_connector_tv_margins {
  499. /**
  500. * @bottom: Bottom margin in pixels.
  501. */
  502. unsigned int bottom;
  503. /**
  504. * @left: Left margin in pixels.
  505. */
  506. unsigned int left;
  507. /**
  508. * @right: Right margin in pixels.
  509. */
  510. unsigned int right;
  511. /**
  512. * @top: Top margin in pixels.
  513. */
  514. unsigned int top;
  515. };
  516. /**
  517. * struct drm_tv_connector_state - TV connector related states
  518. * @subconnector: selected subconnector
  519. * @margins: TV margins
  520. * @mode: TV mode
  521. * @brightness: brightness in percent
  522. * @contrast: contrast in percent
  523. * @flicker_reduction: flicker reduction in percent
  524. * @overscan: overscan in percent
  525. * @saturation: saturation in percent
  526. * @hue: hue in percent
  527. */
  528. struct drm_tv_connector_state {
  529. enum drm_mode_subconnector subconnector;
  530. struct drm_connector_tv_margins margins;
  531. unsigned int mode;
  532. unsigned int brightness;
  533. unsigned int contrast;
  534. unsigned int flicker_reduction;
  535. unsigned int overscan;
  536. unsigned int saturation;
  537. unsigned int hue;
  538. };
  539. /**
  540. * struct drm_connector_state - mutable connector state
  541. */
  542. struct drm_connector_state {
  543. /** @connector: backpointer to the connector */
  544. struct drm_connector *connector;
  545. /**
  546. * @crtc: CRTC to connect connector to, NULL if disabled.
  547. *
  548. * Do not change this directly, use drm_atomic_set_crtc_for_connector()
  549. * instead.
  550. */
  551. struct drm_crtc *crtc;
  552. /**
  553. * @best_encoder:
  554. *
  555. * Used by the atomic helpers to select the encoder, through the
  556. * &drm_connector_helper_funcs.atomic_best_encoder or
  557. * &drm_connector_helper_funcs.best_encoder callbacks.
  558. *
  559. * This is also used in the atomic helpers to map encoders to their
  560. * current and previous connectors, see
  561. * drm_atomic_get_old_connector_for_encoder() and
  562. * drm_atomic_get_new_connector_for_encoder().
  563. *
  564. * NOTE: Atomic drivers must fill this out (either themselves or through
  565. * helpers), for otherwise the GETCONNECTOR and GETENCODER IOCTLs will
  566. * not return correct data to userspace.
  567. */
  568. struct drm_encoder *best_encoder;
  569. /**
  570. * @link_status: Connector link_status to keep track of whether link is
  571. * GOOD or BAD to notify userspace if retraining is necessary.
  572. */
  573. enum drm_link_status link_status;
  574. /** @state: backpointer to global drm_atomic_state */
  575. struct drm_atomic_state *state;
  576. /**
  577. * @commit: Tracks the pending commit to prevent use-after-free conditions.
  578. *
  579. * Is only set when @crtc is NULL.
  580. */
  581. struct drm_crtc_commit *commit;
  582. /** @tv: TV connector state */
  583. struct drm_tv_connector_state tv;
  584. /**
  585. * @self_refresh_aware:
  586. *
  587. * This tracks whether a connector is aware of the self refresh state.
  588. * It should be set to true for those connector implementations which
  589. * understand the self refresh state. This is needed since the crtc
  590. * registers the self refresh helpers and it doesn't know if the
  591. * connectors downstream have implemented self refresh entry/exit.
  592. *
  593. * Drivers should set this to true in atomic_check if they know how to
  594. * handle self_refresh requests.
  595. */
  596. bool self_refresh_aware;
  597. /**
  598. * @picture_aspect_ratio: Connector property to control the
  599. * HDMI infoframe aspect ratio setting.
  600. *
  601. * The %DRM_MODE_PICTURE_ASPECT_\* values much match the
  602. * values for &enum hdmi_picture_aspect
  603. */
  604. enum hdmi_picture_aspect picture_aspect_ratio;
  605. /**
  606. * @content_type: Connector property to control the
  607. * HDMI infoframe content type setting.
  608. * The %DRM_MODE_CONTENT_TYPE_\* values much
  609. * match the values.
  610. */
  611. unsigned int content_type;
  612. /**
  613. * @hdcp_content_type: Connector property to pass the type of
  614. * protected content. This is most commonly used for HDCP.
  615. */
  616. unsigned int hdcp_content_type;
  617. /**
  618. * @scaling_mode: Connector property to control the
  619. * upscaling, mostly used for built-in panels.
  620. */
  621. unsigned int scaling_mode;
  622. /**
  623. * @content_protection: Connector property to request content
  624. * protection. This is most commonly used for HDCP.
  625. */
  626. unsigned int content_protection;
  627. /**
  628. * @colorspace: State variable for Connector property to request
  629. * colorspace change on Sink. This is most commonly used to switch
  630. * to wider color gamuts like BT2020.
  631. */
  632. u32 colorspace;
  633. /**
  634. * @writeback_job: Writeback job for writeback connectors
  635. *
  636. * Holds the framebuffer and out-fence for a writeback connector. As
  637. * the writeback completion may be asynchronous to the normal commit
  638. * cycle, the writeback job lifetime is managed separately from the
  639. * normal atomic state by this object.
  640. *
  641. * See also: drm_writeback_queue_job() and
  642. * drm_writeback_signal_completion()
  643. */
  644. struct drm_writeback_job *writeback_job;
  645. /**
  646. * @max_requested_bpc: Connector property to limit the maximum bit
  647. * depth of the pixels.
  648. */
  649. u8 max_requested_bpc;
  650. /**
  651. * @max_bpc: Connector max_bpc based on the requested max_bpc property
  652. * and the connector bpc limitations obtained from edid.
  653. */
  654. u8 max_bpc;
  655. /**
  656. * @hdr_output_metadata:
  657. * DRM blob property for HDR output metadata
  658. */
  659. struct drm_property_blob *hdr_output_metadata;
  660. };
  661. /**
  662. * struct drm_connector_funcs - control connectors on a given device
  663. *
  664. * Each CRTC may have one or more connectors attached to it. The functions
  665. * below allow the core DRM code to control connectors, enumerate available modes,
  666. * etc.
  667. */
  668. struct drm_connector_funcs {
  669. /**
  670. * @dpms:
  671. *
  672. * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
  673. * is exposed as a standard property on the connector, but diverted to
  674. * this callback in the drm core. Note that atomic drivers don't
  675. * implement the 4 level DPMS support on the connector any more, but
  676. * instead only have an on/off "ACTIVE" property on the CRTC object.
  677. *
  678. * This hook is not used by atomic drivers, remapping of the legacy DPMS
  679. * property is entirely handled in the DRM core.
  680. *
  681. * RETURNS:
  682. *
  683. * 0 on success or a negative error code on failure.
  684. */
  685. int (*dpms)(struct drm_connector *connector, int mode);
  686. /**
  687. * @reset:
  688. *
  689. * Reset connector hardware and software state to off. This function isn't
  690. * called by the core directly, only through drm_mode_config_reset().
  691. * It's not a helper hook only for historical reasons.
  692. *
  693. * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
  694. * atomic state using this hook.
  695. */
  696. void (*reset)(struct drm_connector *connector);
  697. /**
  698. * @detect:
  699. *
  700. * Check to see if anything is attached to the connector. The parameter
  701. * force is set to false whilst polling, true when checking the
  702. * connector due to a user request. force can be used by the driver to
  703. * avoid expensive, destructive operations during automated probing.
  704. *
  705. * This callback is optional, if not implemented the connector will be
  706. * considered as always being attached.
  707. *
  708. * FIXME:
  709. *
  710. * Note that this hook is only called by the probe helper. It's not in
  711. * the helper library vtable purely for historical reasons. The only DRM
  712. * core entry point to probe connector state is @fill_modes.
  713. *
  714. * Note that the helper library will already hold
  715. * &drm_mode_config.connection_mutex. Drivers which need to grab additional
  716. * locks to avoid races with concurrent modeset changes need to use
  717. * &drm_connector_helper_funcs.detect_ctx instead.
  718. *
  719. * RETURNS:
  720. *
  721. * drm_connector_status indicating the connector's status.
  722. */
  723. enum drm_connector_status (*detect)(struct drm_connector *connector,
  724. bool force);
  725. /**
  726. * @force:
  727. *
  728. * This function is called to update internal encoder state when the
  729. * connector is forced to a certain state by userspace, either through
  730. * the sysfs interfaces or on the kernel cmdline. In that case the
  731. * @detect callback isn't called.
  732. *
  733. * FIXME:
  734. *
  735. * Note that this hook is only called by the probe helper. It's not in
  736. * the helper library vtable purely for historical reasons. The only DRM
  737. * core entry point to probe connector state is @fill_modes.
  738. */
  739. void (*force)(struct drm_connector *connector);
  740. /**
  741. * @fill_modes:
  742. *
  743. * Entry point for output detection and basic mode validation. The
  744. * driver should reprobe the output if needed (e.g. when hotplug
  745. * handling is unreliable), add all detected modes to &drm_connector.modes
  746. * and filter out any the device can't support in any configuration. It
  747. * also needs to filter out any modes wider or higher than the
  748. * parameters max_width and max_height indicate.
  749. *
  750. * The drivers must also prune any modes no longer valid from
  751. * &drm_connector.modes. Furthermore it must update
  752. * &drm_connector.status and &drm_connector.edid. If no EDID has been
  753. * received for this output connector->edid must be NULL.
  754. *
  755. * Drivers using the probe helpers should use
  756. * drm_helper_probe_single_connector_modes() to implement this
  757. * function.
  758. *
  759. * RETURNS:
  760. *
  761. * The number of modes detected and filled into &drm_connector.modes.
  762. */
  763. int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
  764. /**
  765. * @set_property:
  766. *
  767. * This is the legacy entry point to update a property attached to the
  768. * connector.
  769. *
  770. * This callback is optional if the driver does not support any legacy
  771. * driver-private properties. For atomic drivers it is not used because
  772. * property handling is done entirely in the DRM core.
  773. *
  774. * RETURNS:
  775. *
  776. * 0 on success or a negative error code on failure.
  777. */
  778. int (*set_property)(struct drm_connector *connector, struct drm_property *property,
  779. uint64_t val);
  780. /**
  781. * @late_register:
  782. *
  783. * This optional hook can be used to register additional userspace
  784. * interfaces attached to the connector, light backlight control, i2c,
  785. * DP aux or similar interfaces. It is called late in the driver load
  786. * sequence from drm_connector_register() when registering all the
  787. * core drm connector interfaces. Everything added from this callback
  788. * should be unregistered in the early_unregister callback.
  789. *
  790. * This is called while holding &drm_connector.mutex.
  791. *
  792. * Returns:
  793. *
  794. * 0 on success, or a negative error code on failure.
  795. */
  796. int (*late_register)(struct drm_connector *connector);
  797. /**
  798. * @early_unregister:
  799. *
  800. * This optional hook should be used to unregister the additional
  801. * userspace interfaces attached to the connector from
  802. * late_register(). It is called from drm_connector_unregister(),
  803. * early in the driver unload sequence to disable userspace access
  804. * before data structures are torndown.
  805. *
  806. * This is called while holding &drm_connector.mutex.
  807. */
  808. void (*early_unregister)(struct drm_connector *connector);
  809. /**
  810. * @destroy:
  811. *
  812. * Clean up connector resources. This is called at driver unload time
  813. * through drm_mode_config_cleanup(). It can also be called at runtime
  814. * when a connector is being hot-unplugged for drivers that support
  815. * connector hotplugging (e.g. DisplayPort MST).
  816. */
  817. void (*destroy)(struct drm_connector *connector);
  818. /**
  819. * @atomic_duplicate_state:
  820. *
  821. * Duplicate the current atomic state for this connector and return it.
  822. * The core and helpers guarantee that any atomic state duplicated with
  823. * this hook and still owned by the caller (i.e. not transferred to the
  824. * driver by calling &drm_mode_config_funcs.atomic_commit) will be
  825. * cleaned up by calling the @atomic_destroy_state hook in this
  826. * structure.
  827. *
  828. * This callback is mandatory for atomic drivers.
  829. *
  830. * Atomic drivers which don't subclass &struct drm_connector_state should use
  831. * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
  832. * state structure to extend it with driver-private state should use
  833. * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
  834. * duplicated in a consistent fashion across drivers.
  835. *
  836. * It is an error to call this hook before &drm_connector.state has been
  837. * initialized correctly.
  838. *
  839. * NOTE:
  840. *
  841. * If the duplicate state references refcounted resources this hook must
  842. * acquire a reference for each of them. The driver must release these
  843. * references again in @atomic_destroy_state.
  844. *
  845. * RETURNS:
  846. *
  847. * Duplicated atomic state or NULL when the allocation failed.
  848. */
  849. struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
  850. /**
  851. * @atomic_destroy_state:
  852. *
  853. * Destroy a state duplicated with @atomic_duplicate_state and release
  854. * or unreference all resources it references
  855. *
  856. * This callback is mandatory for atomic drivers.
  857. */
  858. void (*atomic_destroy_state)(struct drm_connector *connector,
  859. struct drm_connector_state *state);
  860. /**
  861. * @atomic_set_property:
  862. *
  863. * Decode a driver-private property value and store the decoded value
  864. * into the passed-in state structure. Since the atomic core decodes all
  865. * standardized properties (even for extensions beyond the core set of
  866. * properties which might not be implemented by all drivers) this
  867. * requires drivers to subclass the state structure.
  868. *
  869. * Such driver-private properties should really only be implemented for
  870. * truly hardware/vendor specific state. Instead it is preferred to
  871. * standardize atomic extension and decode the properties used to expose
  872. * such an extension in the core.
  873. *
  874. * Do not call this function directly, use
  875. * drm_atomic_connector_set_property() instead.
  876. *
  877. * This callback is optional if the driver does not support any
  878. * driver-private atomic properties.
  879. *
  880. * NOTE:
  881. *
  882. * This function is called in the state assembly phase of atomic
  883. * modesets, which can be aborted for any reason (including on
  884. * userspace's request to just check whether a configuration would be
  885. * possible). Drivers MUST NOT touch any persistent state (hardware or
  886. * software) or data structures except the passed in @state parameter.
  887. *
  888. * Also since userspace controls in which order properties are set this
  889. * function must not do any input validation (since the state update is
  890. * incomplete and hence likely inconsistent). Instead any such input
  891. * validation must be done in the various atomic_check callbacks.
  892. *
  893. * RETURNS:
  894. *
  895. * 0 if the property has been found, -EINVAL if the property isn't
  896. * implemented by the driver (which shouldn't ever happen, the core only
  897. * asks for properties attached to this connector). No other validation
  898. * is allowed by the driver. The core already checks that the property
  899. * value is within the range (integer, valid enum value, ...) the driver
  900. * set when registering the property.
  901. */
  902. int (*atomic_set_property)(struct drm_connector *connector,
  903. struct drm_connector_state *state,
  904. struct drm_property *property,
  905. uint64_t val);
  906. /**
  907. * @atomic_get_property:
  908. *
  909. * Reads out the decoded driver-private property. This is used to
  910. * implement the GETCONNECTOR IOCTL.
  911. *
  912. * Do not call this function directly, use
  913. * drm_atomic_connector_get_property() instead.
  914. *
  915. * This callback is optional if the driver does not support any
  916. * driver-private atomic properties.
  917. *
  918. * RETURNS:
  919. *
  920. * 0 on success, -EINVAL if the property isn't implemented by the
  921. * driver (which shouldn't ever happen, the core only asks for
  922. * properties attached to this connector).
  923. */
  924. int (*atomic_get_property)(struct drm_connector *connector,
  925. const struct drm_connector_state *state,
  926. struct drm_property *property,
  927. uint64_t *val);
  928. /**
  929. * @atomic_print_state:
  930. *
  931. * If driver subclasses &struct drm_connector_state, it should implement
  932. * this optional hook for printing additional driver specific state.
  933. *
  934. * Do not call this directly, use drm_atomic_connector_print_state()
  935. * instead.
  936. */
  937. void (*atomic_print_state)(struct drm_printer *p,
  938. const struct drm_connector_state *state);
  939. };
  940. /**
  941. * struct drm_cmdline_mode - DRM Mode passed through the kernel command-line
  942. *
  943. * Each connector can have an initial mode with additional options
  944. * passed through the kernel command line. This structure allows to
  945. * express those parameters and will be filled by the command-line
  946. * parser.
  947. */
  948. struct drm_cmdline_mode {
  949. /**
  950. * @name:
  951. *
  952. * Name of the mode.
  953. */
  954. char name[DRM_DISPLAY_MODE_LEN];
  955. /**
  956. * @specified:
  957. *
  958. * Has a mode been read from the command-line?
  959. */
  960. bool specified;
  961. /**
  962. * @refresh_specified:
  963. *
  964. * Did the mode have a preferred refresh rate?
  965. */
  966. bool refresh_specified;
  967. /**
  968. * @bpp_specified:
  969. *
  970. * Did the mode have a preferred BPP?
  971. */
  972. bool bpp_specified;
  973. /**
  974. * @xres:
  975. *
  976. * Active resolution on the X axis, in pixels.
  977. */
  978. int xres;
  979. /**
  980. * @yres:
  981. *
  982. * Active resolution on the Y axis, in pixels.
  983. */
  984. int yres;
  985. /**
  986. * @bpp:
  987. *
  988. * Bits per pixels for the mode.
  989. */
  990. int bpp;
  991. /**
  992. * @refresh:
  993. *
  994. * Refresh rate, in Hertz.
  995. */
  996. int refresh;
  997. /**
  998. * @rb:
  999. *
  1000. * Do we need to use reduced blanking?
  1001. */
  1002. bool rb;
  1003. /**
  1004. * @interlace:
  1005. *
  1006. * The mode is interlaced.
  1007. */
  1008. bool interlace;
  1009. /**
  1010. * @cvt:
  1011. *
  1012. * The timings will be calculated using the VESA Coordinated
  1013. * Video Timings instead of looking up the mode from a table.
  1014. */
  1015. bool cvt;
  1016. /**
  1017. * @margins:
  1018. *
  1019. * Add margins to the mode calculation (1.8% of xres rounded
  1020. * down to 8 pixels and 1.8% of yres).
  1021. */
  1022. bool margins;
  1023. /**
  1024. * @force:
  1025. *
  1026. * Ignore the hotplug state of the connector, and force its
  1027. * state to one of the DRM_FORCE_* values.
  1028. */
  1029. enum drm_connector_force force;
  1030. /**
  1031. * @rotation_reflection:
  1032. *
  1033. * Initial rotation and reflection of the mode setup from the
  1034. * command line. See DRM_MODE_ROTATE_* and
  1035. * DRM_MODE_REFLECT_*. The only rotations supported are
  1036. * DRM_MODE_ROTATE_0 and DRM_MODE_ROTATE_180.
  1037. */
  1038. unsigned int rotation_reflection;
  1039. /**
  1040. * @panel_orientation:
  1041. *
  1042. * drm-connector "panel orientation" property override value,
  1043. * DRM_MODE_PANEL_ORIENTATION_UNKNOWN if not set.
  1044. */
  1045. enum drm_panel_orientation panel_orientation;
  1046. /**
  1047. * @tv_margins: TV margins to apply to the mode.
  1048. */
  1049. struct drm_connector_tv_margins tv_margins;
  1050. };
  1051. /**
  1052. * struct drm_connector - central DRM connector control structure
  1053. *
  1054. * Each connector may be connected to one or more CRTCs, or may be clonable by
  1055. * another connector if they can share a CRTC. Each connector also has a specific
  1056. * position in the broader display (referred to as a 'screen' though it could
  1057. * span multiple monitors).
  1058. */
  1059. struct drm_connector {
  1060. /** @dev: parent DRM device */
  1061. struct drm_device *dev;
  1062. /** @kdev: kernel device for sysfs attributes */
  1063. struct device *kdev;
  1064. /** @attr: sysfs attributes */
  1065. struct device_attribute *attr;
  1066. /**
  1067. * @head:
  1068. *
  1069. * List of all connectors on a @dev, linked from
  1070. * &drm_mode_config.connector_list. Protected by
  1071. * &drm_mode_config.connector_list_lock, but please only use
  1072. * &drm_connector_list_iter to walk this list.
  1073. */
  1074. struct list_head head;
  1075. /** @base: base KMS object */
  1076. struct drm_mode_object base;
  1077. /** @name: human readable name, can be overwritten by the driver */
  1078. char *name;
  1079. /**
  1080. * @mutex: Lock for general connector state, but currently only protects
  1081. * @registered. Most of the connector state is still protected by
  1082. * &drm_mode_config.mutex.
  1083. */
  1084. struct mutex mutex;
  1085. /**
  1086. * @index: Compacted connector index, which matches the position inside
  1087. * the mode_config.list for drivers not supporting hot-add/removing. Can
  1088. * be used as an array index. It is invariant over the lifetime of the
  1089. * connector.
  1090. */
  1091. unsigned index;
  1092. /**
  1093. * @connector_type:
  1094. * one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
  1095. */
  1096. int connector_type;
  1097. /** @connector_type_id: index into connector type enum */
  1098. int connector_type_id;
  1099. /**
  1100. * @interlace_allowed:
  1101. * Can this connector handle interlaced modes? Only used by
  1102. * drm_helper_probe_single_connector_modes() for mode filtering.
  1103. */
  1104. bool interlace_allowed;
  1105. /**
  1106. * @doublescan_allowed:
  1107. * Can this connector handle doublescan? Only used by
  1108. * drm_helper_probe_single_connector_modes() for mode filtering.
  1109. */
  1110. bool doublescan_allowed;
  1111. /**
  1112. * @stereo_allowed:
  1113. * Can this connector handle stereo modes? Only used by
  1114. * drm_helper_probe_single_connector_modes() for mode filtering.
  1115. */
  1116. bool stereo_allowed;
  1117. /**
  1118. * @ycbcr_420_allowed : This bool indicates if this connector is
  1119. * capable of handling YCBCR 420 output. While parsing the EDID
  1120. * blocks it's very helpful to know if the source is capable of
  1121. * handling YCBCR 420 outputs.
  1122. */
  1123. bool ycbcr_420_allowed;
  1124. /**
  1125. * @registration_state: Is this connector initializing, exposed
  1126. * (registered) with userspace, or unregistered?
  1127. *
  1128. * Protected by @mutex.
  1129. */
  1130. enum drm_connector_registration_state registration_state;
  1131. /**
  1132. * @modes:
  1133. * Modes available on this connector (from fill_modes() + user).
  1134. * Protected by &drm_mode_config.mutex.
  1135. */
  1136. struct list_head modes;
  1137. /**
  1138. * @status:
  1139. * One of the drm_connector_status enums (connected, not, or unknown).
  1140. * Protected by &drm_mode_config.mutex.
  1141. */
  1142. enum drm_connector_status status;
  1143. /**
  1144. * @probed_modes:
  1145. * These are modes added by probing with DDC or the BIOS, before
  1146. * filtering is applied. Used by the probe helpers. Protected by
  1147. * &drm_mode_config.mutex.
  1148. */
  1149. struct list_head probed_modes;
  1150. /**
  1151. * @display_info: Display information is filled from EDID information
  1152. * when a display is detected. For non hot-pluggable displays such as
  1153. * flat panels in embedded systems, the driver should initialize the
  1154. * &drm_display_info.width_mm and &drm_display_info.height_mm fields
  1155. * with the physical size of the display.
  1156. *
  1157. * Protected by &drm_mode_config.mutex.
  1158. */
  1159. struct drm_display_info display_info;
  1160. /** @funcs: connector control functions */
  1161. const struct drm_connector_funcs *funcs;
  1162. /**
  1163. * @edid_blob_ptr: DRM property containing EDID if present. Protected by
  1164. * &drm_mode_config.mutex. This should be updated only by calling
  1165. * drm_connector_update_edid_property().
  1166. */
  1167. struct drm_property_blob *edid_blob_ptr;
  1168. /** @properties: property tracking for this connector */
  1169. struct drm_object_properties properties;
  1170. /**
  1171. * @scaling_mode_property: Optional atomic property to control the
  1172. * upscaling. See drm_connector_attach_content_protection_property().
  1173. */
  1174. struct drm_property *scaling_mode_property;
  1175. /**
  1176. * @vrr_capable_property: Optional property to help userspace
  1177. * query hardware support for variable refresh rate on a connector.
  1178. * connector. Drivers can add the property to a connector by
  1179. * calling drm_connector_attach_vrr_capable_property().
  1180. *
  1181. * This should be updated only by calling
  1182. * drm_connector_set_vrr_capable_property().
  1183. */
  1184. struct drm_property *vrr_capable_property;
  1185. /**
  1186. * @colorspace_property: Connector property to set the suitable
  1187. * colorspace supported by the sink.
  1188. */
  1189. struct drm_property *colorspace_property;
  1190. /**
  1191. * @path_blob_ptr:
  1192. *
  1193. * DRM blob property data for the DP MST path property. This should only
  1194. * be updated by calling drm_connector_set_path_property().
  1195. */
  1196. struct drm_property_blob *path_blob_ptr;
  1197. /**
  1198. * @max_bpc_property: Default connector property for the max bpc to be
  1199. * driven out of the connector.
  1200. */
  1201. struct drm_property *max_bpc_property;
  1202. #define DRM_CONNECTOR_POLL_HPD (1 << 0)
  1203. #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
  1204. #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
  1205. /**
  1206. * @polled:
  1207. *
  1208. * Connector polling mode, a combination of
  1209. *
  1210. * DRM_CONNECTOR_POLL_HPD
  1211. * The connector generates hotplug events and doesn't need to be
  1212. * periodically polled. The CONNECT and DISCONNECT flags must not
  1213. * be set together with the HPD flag.
  1214. *
  1215. * DRM_CONNECTOR_POLL_CONNECT
  1216. * Periodically poll the connector for connection.
  1217. *
  1218. * DRM_CONNECTOR_POLL_DISCONNECT
  1219. * Periodically poll the connector for disconnection, without
  1220. * causing flickering even when the connector is in use. DACs should
  1221. * rarely do this without a lot of testing.
  1222. *
  1223. * Set to 0 for connectors that don't support connection status
  1224. * discovery.
  1225. */
  1226. uint8_t polled;
  1227. /**
  1228. * @dpms: Current dpms state. For legacy drivers the
  1229. * &drm_connector_funcs.dpms callback must update this. For atomic
  1230. * drivers, this is handled by the core atomic code, and drivers must
  1231. * only take &drm_crtc_state.active into account.
  1232. */
  1233. int dpms;
  1234. /** @helper_private: mid-layer private data */
  1235. const struct drm_connector_helper_funcs *helper_private;
  1236. /** @cmdline_mode: mode line parsed from the kernel cmdline for this connector */
  1237. struct drm_cmdline_mode cmdline_mode;
  1238. /** @force: a DRM_FORCE_<foo> state for forced mode sets */
  1239. enum drm_connector_force force;
  1240. /** @override_edid: has the EDID been overwritten through debugfs for testing? */
  1241. bool override_edid;
  1242. /** @epoch_counter: used to detect any other changes in connector, besides status */
  1243. u64 epoch_counter;
  1244. /**
  1245. * @possible_encoders: Bit mask of encoders that can drive this
  1246. * connector, drm_encoder_index() determines the index into the bitfield
  1247. * and the bits are set with drm_connector_attach_encoder().
  1248. */
  1249. u32 possible_encoders;
  1250. /**
  1251. * @encoder: Currently bound encoder driving this connector, if any.
  1252. * Only really meaningful for non-atomic drivers. Atomic drivers should
  1253. * instead look at &drm_connector_state.best_encoder, and in case they
  1254. * need the CRTC driving this output, &drm_connector_state.crtc.
  1255. */
  1256. struct drm_encoder *encoder;
  1257. #define MAX_ELD_BYTES 128
  1258. /** @eld: EDID-like data, if present */
  1259. uint8_t eld[MAX_ELD_BYTES];
  1260. /** @latency_present: AV delay info from ELD, if found */
  1261. bool latency_present[2];
  1262. /**
  1263. * @video_latency: Video latency info from ELD, if found.
  1264. * [0]: progressive, [1]: interlaced
  1265. */
  1266. int video_latency[2];
  1267. /**
  1268. * @audio_latency: audio latency info from ELD, if found
  1269. * [0]: progressive, [1]: interlaced
  1270. */
  1271. int audio_latency[2];
  1272. /**
  1273. * @ddc: associated ddc adapter.
  1274. * A connector usually has its associated ddc adapter. If a driver uses
  1275. * this field, then an appropriate symbolic link is created in connector
  1276. * sysfs directory to make it easy for the user to tell which i2c
  1277. * adapter is for a particular display.
  1278. *
  1279. * The field should be set by calling drm_connector_init_with_ddc().
  1280. */
  1281. struct i2c_adapter *ddc;
  1282. /**
  1283. * @null_edid_counter: track sinks that give us all zeros for the EDID.
  1284. * Needed to workaround some HW bugs where we get all 0s
  1285. */
  1286. int null_edid_counter;
  1287. /** @bad_edid_counter: track sinks that give us an EDID with invalid checksum */
  1288. unsigned bad_edid_counter;
  1289. /**
  1290. * @edid_corrupt: Indicates whether the last read EDID was corrupt. Used
  1291. * in Displayport compliance testing - Displayport Link CTS Core 1.2
  1292. * rev1.1 4.2.2.6
  1293. */
  1294. bool edid_corrupt;
  1295. /**
  1296. * @real_edid_checksum: real edid checksum for corrupted edid block.
  1297. * Required in Displayport 1.4 compliance testing
  1298. * rev1.1 4.2.2.6
  1299. */
  1300. u8 real_edid_checksum;
  1301. /** @debugfs_entry: debugfs directory for this connector */
  1302. struct dentry *debugfs_entry;
  1303. /**
  1304. * @state:
  1305. *
  1306. * Current atomic state for this connector.
  1307. *
  1308. * This is protected by &drm_mode_config.connection_mutex. Note that
  1309. * nonblocking atomic commits access the current connector state without
  1310. * taking locks. Either by going through the &struct drm_atomic_state
  1311. * pointers, see for_each_oldnew_connector_in_state(),
  1312. * for_each_old_connector_in_state() and
  1313. * for_each_new_connector_in_state(). Or through careful ordering of
  1314. * atomic commit operations as implemented in the atomic helpers, see
  1315. * &struct drm_crtc_commit.
  1316. */
  1317. struct drm_connector_state *state;
  1318. /* DisplayID bits. FIXME: Extract into a substruct? */
  1319. /**
  1320. * @tile_blob_ptr:
  1321. *
  1322. * DRM blob property data for the tile property (used mostly by DP MST).
  1323. * This is meant for screens which are driven through separate display
  1324. * pipelines represented by &drm_crtc, which might not be running with
  1325. * genlocked clocks. For tiled panels which are genlocked, like
  1326. * dual-link LVDS or dual-link DSI, the driver should try to not expose
  1327. * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
  1328. *
  1329. * This should only be updated by calling
  1330. * drm_connector_set_tile_property().
  1331. */
  1332. struct drm_property_blob *tile_blob_ptr;
  1333. /** @has_tile: is this connector connected to a tiled monitor */
  1334. bool has_tile;
  1335. /** @tile_group: tile group for the connected monitor */
  1336. struct drm_tile_group *tile_group;
  1337. /** @tile_is_single_monitor: whether the tile is one monitor housing */
  1338. bool tile_is_single_monitor;
  1339. /** @num_h_tile: number of horizontal tiles in the tile group */
  1340. /** @num_v_tile: number of vertical tiles in the tile group */
  1341. uint8_t num_h_tile, num_v_tile;
  1342. /** @tile_h_loc: horizontal location of this tile */
  1343. /** @tile_v_loc: vertical location of this tile */
  1344. uint8_t tile_h_loc, tile_v_loc;
  1345. /** @tile_h_size: horizontal size of this tile. */
  1346. /** @tile_v_size: vertical size of this tile. */
  1347. uint16_t tile_h_size, tile_v_size;
  1348. /**
  1349. * @free_node:
  1350. *
  1351. * List used only by &drm_connector_list_iter to be able to clean up a
  1352. * connector from any context, in conjunction with
  1353. * &drm_mode_config.connector_free_work.
  1354. */
  1355. struct llist_node free_node;
  1356. /** @hdr_sink_metadata: HDR Metadata Information read from sink */
  1357. struct hdr_sink_metadata hdr_sink_metadata;
  1358. };
  1359. #define obj_to_connector(x) container_of(x, struct drm_connector, base)
  1360. int drm_connector_init(struct drm_device *dev,
  1361. struct drm_connector *connector,
  1362. const struct drm_connector_funcs *funcs,
  1363. int connector_type);
  1364. int drm_connector_init_with_ddc(struct drm_device *dev,
  1365. struct drm_connector *connector,
  1366. const struct drm_connector_funcs *funcs,
  1367. int connector_type,
  1368. struct i2c_adapter *ddc);
  1369. void drm_connector_attach_edid_property(struct drm_connector *connector);
  1370. int drm_connector_register(struct drm_connector *connector);
  1371. void drm_connector_unregister(struct drm_connector *connector);
  1372. int drm_connector_attach_encoder(struct drm_connector *connector,
  1373. struct drm_encoder *encoder);
  1374. void drm_connector_cleanup(struct drm_connector *connector);
  1375. static inline unsigned int drm_connector_index(const struct drm_connector *connector)
  1376. {
  1377. return connector->index;
  1378. }
  1379. static inline u32 drm_connector_mask(const struct drm_connector *connector)
  1380. {
  1381. return 1 << connector->index;
  1382. }
  1383. /**
  1384. * drm_connector_lookup - lookup connector object
  1385. * @dev: DRM device
  1386. * @file_priv: drm file to check for lease against.
  1387. * @id: connector object id
  1388. *
  1389. * This function looks up the connector object specified by id
  1390. * add takes a reference to it.
  1391. */
  1392. static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
  1393. struct drm_file *file_priv,
  1394. uint32_t id)
  1395. {
  1396. struct drm_mode_object *mo;
  1397. mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CONNECTOR);
  1398. return mo ? obj_to_connector(mo) : NULL;
  1399. }
  1400. /**
  1401. * drm_connector_get - acquire a connector reference
  1402. * @connector: DRM connector
  1403. *
  1404. * This function increments the connector's refcount.
  1405. */
  1406. static inline void drm_connector_get(struct drm_connector *connector)
  1407. {
  1408. drm_mode_object_get(&connector->base);
  1409. }
  1410. /**
  1411. * drm_connector_put - release a connector reference
  1412. * @connector: DRM connector
  1413. *
  1414. * This function decrements the connector's reference count and frees the
  1415. * object if the reference count drops to zero.
  1416. */
  1417. static inline void drm_connector_put(struct drm_connector *connector)
  1418. {
  1419. drm_mode_object_put(&connector->base);
  1420. }
  1421. /**
  1422. * drm_connector_is_unregistered - has the connector been unregistered from
  1423. * userspace?
  1424. * @connector: DRM connector
  1425. *
  1426. * Checks whether or not @connector has been unregistered from userspace.
  1427. *
  1428. * Returns:
  1429. * True if the connector was unregistered, false if the connector is
  1430. * registered or has not yet been registered with userspace.
  1431. */
  1432. static inline bool
  1433. drm_connector_is_unregistered(struct drm_connector *connector)
  1434. {
  1435. return READ_ONCE(connector->registration_state) ==
  1436. DRM_CONNECTOR_UNREGISTERED;
  1437. }
  1438. const char *drm_get_connector_type_name(unsigned int connector_type);
  1439. const char *drm_get_connector_status_name(enum drm_connector_status status);
  1440. const char *drm_get_subpixel_order_name(enum subpixel_order order);
  1441. const char *drm_get_dpms_name(int val);
  1442. const char *drm_get_dvi_i_subconnector_name(int val);
  1443. const char *drm_get_dvi_i_select_name(int val);
  1444. const char *drm_get_tv_subconnector_name(int val);
  1445. const char *drm_get_tv_select_name(int val);
  1446. const char *drm_get_dp_subconnector_name(int val);
  1447. const char *drm_get_content_protection_name(int val);
  1448. const char *drm_get_hdcp_content_type_name(int val);
  1449. int drm_mode_create_dvi_i_properties(struct drm_device *dev);
  1450. void drm_connector_attach_dp_subconnector_property(struct drm_connector *connector);
  1451. int drm_mode_create_tv_margin_properties(struct drm_device *dev);
  1452. int drm_mode_create_tv_properties(struct drm_device *dev,
  1453. unsigned int num_modes,
  1454. const char * const modes[]);
  1455. void drm_connector_attach_tv_margin_properties(struct drm_connector *conn);
  1456. int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  1457. int drm_connector_attach_content_type_property(struct drm_connector *dev);
  1458. int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
  1459. u32 scaling_mode_mask);
  1460. int drm_connector_attach_vrr_capable_property(
  1461. struct drm_connector *connector);
  1462. int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
  1463. int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector);
  1464. int drm_mode_create_dp_colorspace_property(struct drm_connector *connector);
  1465. int drm_mode_create_content_type_property(struct drm_device *dev);
  1466. void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe *frame,
  1467. const struct drm_connector_state *conn_state);
  1468. int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
  1469. int drm_connector_set_path_property(struct drm_connector *connector,
  1470. const char *path);
  1471. int drm_connector_set_tile_property(struct drm_connector *connector);
  1472. int drm_connector_update_edid_property(struct drm_connector *connector,
  1473. const struct edid *edid);
  1474. void drm_connector_set_link_status_property(struct drm_connector *connector,
  1475. uint64_t link_status);
  1476. void drm_connector_set_vrr_capable_property(
  1477. struct drm_connector *connector, bool capable);
  1478. int drm_connector_set_panel_orientation(
  1479. struct drm_connector *connector,
  1480. enum drm_panel_orientation panel_orientation);
  1481. int drm_connector_set_panel_orientation_with_quirk(
  1482. struct drm_connector *connector,
  1483. enum drm_panel_orientation panel_orientation,
  1484. int width, int height);
  1485. int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
  1486. int min, int max);
  1487. /**
  1488. * struct drm_tile_group - Tile group metadata
  1489. * @refcount: reference count
  1490. * @dev: DRM device
  1491. * @id: tile group id exposed to userspace
  1492. * @group_data: Sink-private data identifying this group
  1493. *
  1494. * @group_data corresponds to displayid vend/prod/serial for external screens
  1495. * with an EDID.
  1496. */
  1497. struct drm_tile_group {
  1498. struct kref refcount;
  1499. struct drm_device *dev;
  1500. int id;
  1501. u8 group_data[8];
  1502. };
  1503. struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
  1504. const char topology[8]);
  1505. struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
  1506. const char topology[8]);
  1507. void drm_mode_put_tile_group(struct drm_device *dev,
  1508. struct drm_tile_group *tg);
  1509. /**
  1510. * struct drm_connector_list_iter - connector_list iterator
  1511. *
  1512. * This iterator tracks state needed to be able to walk the connector_list
  1513. * within struct drm_mode_config. Only use together with
  1514. * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and
  1515. * drm_connector_list_iter_next() respectively the convenience macro
  1516. * drm_for_each_connector_iter().
  1517. */
  1518. struct drm_connector_list_iter {
  1519. /* private: */
  1520. struct drm_device *dev;
  1521. struct drm_connector *conn;
  1522. };
  1523. void drm_connector_list_iter_begin(struct drm_device *dev,
  1524. struct drm_connector_list_iter *iter);
  1525. struct drm_connector *
  1526. drm_connector_list_iter_next(struct drm_connector_list_iter *iter);
  1527. void drm_connector_list_iter_end(struct drm_connector_list_iter *iter);
  1528. bool drm_connector_has_possible_encoder(struct drm_connector *connector,
  1529. struct drm_encoder *encoder);
  1530. /**
  1531. * drm_for_each_connector_iter - connector_list iterator macro
  1532. * @connector: &struct drm_connector pointer used as cursor
  1533. * @iter: &struct drm_connector_list_iter
  1534. *
  1535. * Note that @connector is only valid within the list body, if you want to use
  1536. * @connector after calling drm_connector_list_iter_end() then you need to grab
  1537. * your own reference first using drm_connector_get().
  1538. */
  1539. #define drm_for_each_connector_iter(connector, iter) \
  1540. while ((connector = drm_connector_list_iter_next(iter)))
  1541. /**
  1542. * drm_connector_for_each_possible_encoder - iterate connector's possible encoders
  1543. * @connector: &struct drm_connector pointer
  1544. * @encoder: &struct drm_encoder pointer used as cursor
  1545. */
  1546. #define drm_connector_for_each_possible_encoder(connector, encoder) \
  1547. drm_for_each_encoder_mask(encoder, (connector)->dev, \
  1548. (connector)->possible_encoders)
  1549. #endif