drm_connector.h 35 KB

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