drm_connector.h 43 KB

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