drm_connector.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  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 <drm/drm_mode_object.h>
  27. #include <uapi/drm/drm_mode.h>
  28. struct drm_device;
  29. struct drm_connector_helper_funcs;
  30. struct drm_device;
  31. struct drm_crtc;
  32. struct drm_encoder;
  33. struct drm_property;
  34. struct drm_property_blob;
  35. struct edid;
  36. enum drm_connector_force {
  37. DRM_FORCE_UNSPECIFIED,
  38. DRM_FORCE_OFF,
  39. DRM_FORCE_ON, /* force on analog part normally */
  40. DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
  41. };
  42. /**
  43. * enum drm_connector_status - status for a &drm_connector
  44. *
  45. * This enum is used to track the connector status. There are no separate
  46. * #defines for the uapi!
  47. */
  48. enum drm_connector_status {
  49. /**
  50. * @connector_status_connected: The connector is definitely connected to
  51. * a sink device, and can be enabled.
  52. */
  53. connector_status_connected = 1,
  54. /**
  55. * @connector_status_disconnected: The connector isn't connected to a
  56. * sink device which can be autodetect. For digital outputs like DP or
  57. * HDMI (which can be realiable probed) this means there's really
  58. * nothing there. It is driver-dependent whether a connector with this
  59. * status can be lit up or not.
  60. */
  61. connector_status_disconnected = 2,
  62. /**
  63. * @connector_status_unknown: The connector's status could not be
  64. * reliably detected. This happens when probing would either cause
  65. * flicker (like load-detection when the connector is in use), or when a
  66. * hardware resource isn't available (like when load-detection needs a
  67. * free CRTC). It should be possible to light up the connector with one
  68. * of the listed fallback modes. For default configuration userspace
  69. * should only try to light up connectors with unknown status when
  70. * there's not connector with @connector_status_connected.
  71. */
  72. connector_status_unknown = 3,
  73. };
  74. enum subpixel_order {
  75. SubPixelUnknown = 0,
  76. SubPixelHorizontalRGB,
  77. SubPixelHorizontalBGR,
  78. SubPixelVerticalRGB,
  79. SubPixelVerticalBGR,
  80. SubPixelNone,
  81. };
  82. /**
  83. * struct drm_display_info - runtime data about the connected sink
  84. *
  85. * Describes a given display (e.g. CRT or flat panel) and its limitations. For
  86. * fixed display sinks like built-in panels there's not much difference between
  87. * this and struct &drm_connector. But for sinks with a real cable this
  88. * structure is meant to describe all the things at the other end of the cable.
  89. *
  90. * For sinks which provide an EDID this can be filled out by calling
  91. * drm_add_edid_modes().
  92. */
  93. struct drm_display_info {
  94. /**
  95. * @name: Name of the display.
  96. */
  97. char name[DRM_DISPLAY_INFO_LEN];
  98. /**
  99. * @width_mm: Physical width in mm.
  100. */
  101. unsigned int width_mm;
  102. /**
  103. * @height_mm: Physical height in mm.
  104. */
  105. unsigned int height_mm;
  106. /**
  107. * @pixel_clock: Maximum pixel clock supported by the sink, in units of
  108. * 100Hz. This mismatches the clok in &drm_display_mode (which is in
  109. * kHZ), because that's what the EDID uses as base unit.
  110. */
  111. unsigned int pixel_clock;
  112. /**
  113. * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
  114. */
  115. unsigned int bpc;
  116. /**
  117. * @subpixel_order: Subpixel order of LCD panels.
  118. */
  119. enum subpixel_order subpixel_order;
  120. #define DRM_COLOR_FORMAT_RGB444 (1<<0)
  121. #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
  122. #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
  123. /**
  124. * @color_formats: HDMI Color formats, selects between RGB and YCrCb
  125. * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones
  126. * as used to describe the pixel format in framebuffers, and also don't
  127. * match the formats in @bus_formats which are shared with v4l.
  128. */
  129. u32 color_formats;
  130. /**
  131. * @bus_formats: Pixel data format on the wire, somewhat redundant with
  132. * @color_formats. Array of size @num_bus_formats encoded using
  133. * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
  134. */
  135. const u32 *bus_formats;
  136. /**
  137. * @num_bus_formats: Size of @bus_formats array.
  138. */
  139. unsigned int num_bus_formats;
  140. #define DRM_BUS_FLAG_DE_LOW (1<<0)
  141. #define DRM_BUS_FLAG_DE_HIGH (1<<1)
  142. /* drive data on pos. edge */
  143. #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2)
  144. /* drive data on neg. edge */
  145. #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3)
  146. /**
  147. * @bus_flags: Additional information (like pixel signal polarity) for
  148. * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines.
  149. */
  150. u32 bus_flags;
  151. /**
  152. * @max_tmds_clock: Maximum TMDS clock rate supported by the
  153. * sink in kHz. 0 means undefined.
  154. */
  155. int max_tmds_clock;
  156. /**
  157. * @dvi_dual: Dual-link DVI sink?
  158. */
  159. bool dvi_dual;
  160. /**
  161. * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
  162. * more stuff redundant with @bus_formats.
  163. */
  164. u8 edid_hdmi_dc_modes;
  165. /**
  166. * @cea_rev: CEA revision of the HDMI sink.
  167. */
  168. u8 cea_rev;
  169. };
  170. int drm_display_info_set_bus_formats(struct drm_display_info *info,
  171. const u32 *formats,
  172. unsigned int num_formats);
  173. /**
  174. * struct drm_connector_state - mutable connector state
  175. * @connector: backpointer to the connector
  176. * @best_encoder: can be used by helpers and drivers to select the encoder
  177. * @state: backpointer to global drm_atomic_state
  178. */
  179. struct drm_connector_state {
  180. struct drm_connector *connector;
  181. /**
  182. * @crtc: CRTC to connect connector to, NULL if disabled.
  183. *
  184. * Do not change this directly, use drm_atomic_set_crtc_for_connector()
  185. * instead.
  186. */
  187. struct drm_crtc *crtc;
  188. struct drm_encoder *best_encoder;
  189. struct drm_atomic_state *state;
  190. };
  191. /**
  192. * struct drm_connector_funcs - control connectors on a given device
  193. *
  194. * Each CRTC may have one or more connectors attached to it. The functions
  195. * below allow the core DRM code to control connectors, enumerate available modes,
  196. * etc.
  197. */
  198. struct drm_connector_funcs {
  199. /**
  200. * @dpms:
  201. *
  202. * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
  203. * is exposed as a standard property on the connector, but diverted to
  204. * this callback in the drm core. Note that atomic drivers don't
  205. * implement the 4 level DPMS support on the connector any more, but
  206. * instead only have an on/off "ACTIVE" property on the CRTC object.
  207. *
  208. * Drivers implementing atomic modeset should use
  209. * drm_atomic_helper_connector_dpms() to implement this hook.
  210. *
  211. * RETURNS:
  212. *
  213. * 0 on success or a negative error code on failure.
  214. */
  215. int (*dpms)(struct drm_connector *connector, int mode);
  216. /**
  217. * @reset:
  218. *
  219. * Reset connector hardware and software state to off. This function isn't
  220. * called by the core directly, only through drm_mode_config_reset().
  221. * It's not a helper hook only for historical reasons.
  222. *
  223. * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
  224. * atomic state using this hook.
  225. */
  226. void (*reset)(struct drm_connector *connector);
  227. /**
  228. * @detect:
  229. *
  230. * Check to see if anything is attached to the connector. The parameter
  231. * force is set to false whilst polling, true when checking the
  232. * connector due to a user request. force can be used by the driver to
  233. * avoid expensive, destructive operations during automated probing.
  234. *
  235. * FIXME:
  236. *
  237. * Note that this hook is only called by the probe helper. It's not in
  238. * the helper library vtable purely for historical reasons. The only DRM
  239. * core entry point to probe connector state is @fill_modes.
  240. *
  241. * RETURNS:
  242. *
  243. * drm_connector_status indicating the connector's status.
  244. */
  245. enum drm_connector_status (*detect)(struct drm_connector *connector,
  246. bool force);
  247. /**
  248. * @force:
  249. *
  250. * This function is called to update internal encoder state when the
  251. * connector is forced to a certain state by userspace, either through
  252. * the sysfs interfaces or on the kernel cmdline. In that case the
  253. * @detect callback isn't called.
  254. *
  255. * FIXME:
  256. *
  257. * Note that this hook is only called by the probe helper. It's not in
  258. * the helper library vtable purely for historical reasons. The only DRM
  259. * core entry point to probe connector state is @fill_modes.
  260. */
  261. void (*force)(struct drm_connector *connector);
  262. /**
  263. * @fill_modes:
  264. *
  265. * Entry point for output detection and basic mode validation. The
  266. * driver should reprobe the output if needed (e.g. when hotplug
  267. * handling is unreliable), add all detected modes to connector->modes
  268. * and filter out any the device can't support in any configuration. It
  269. * also needs to filter out any modes wider or higher than the
  270. * parameters max_width and max_height indicate.
  271. *
  272. * The drivers must also prune any modes no longer valid from
  273. * connector->modes. Furthermore it must update connector->status and
  274. * connector->edid. If no EDID has been received for this output
  275. * connector->edid must be NULL.
  276. *
  277. * Drivers using the probe helpers should use
  278. * drm_helper_probe_single_connector_modes() or
  279. * drm_helper_probe_single_connector_modes_nomerge() to implement this
  280. * function.
  281. *
  282. * RETURNS:
  283. *
  284. * The number of modes detected and filled into connector->modes.
  285. */
  286. int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
  287. /**
  288. * @set_property:
  289. *
  290. * This is the legacy entry point to update a property attached to the
  291. * connector.
  292. *
  293. * Drivers implementing atomic modeset should use
  294. * drm_atomic_helper_connector_set_property() to implement this hook.
  295. *
  296. * This callback is optional if the driver does not support any legacy
  297. * driver-private properties.
  298. *
  299. * RETURNS:
  300. *
  301. * 0 on success or a negative error code on failure.
  302. */
  303. int (*set_property)(struct drm_connector *connector, struct drm_property *property,
  304. uint64_t val);
  305. /**
  306. * @late_register:
  307. *
  308. * This optional hook can be used to register additional userspace
  309. * interfaces attached to the connector, light backlight control, i2c,
  310. * DP aux or similar interfaces. It is called late in the driver load
  311. * sequence from drm_connector_register() when registering all the
  312. * core drm connector interfaces. Everything added from this callback
  313. * should be unregistered in the early_unregister callback.
  314. *
  315. * This is called while holding drm_connector->mutex.
  316. *
  317. * Returns:
  318. *
  319. * 0 on success, or a negative error code on failure.
  320. */
  321. int (*late_register)(struct drm_connector *connector);
  322. /**
  323. * @early_unregister:
  324. *
  325. * This optional hook should be used to unregister the additional
  326. * userspace interfaces attached to the connector from
  327. * late_register(). It is called from drm_connector_unregister(),
  328. * early in the driver unload sequence to disable userspace access
  329. * before data structures are torndown.
  330. *
  331. * This is called while holding drm_connector->mutex.
  332. */
  333. void (*early_unregister)(struct drm_connector *connector);
  334. /**
  335. * @destroy:
  336. *
  337. * Clean up connector resources. This is called at driver unload time
  338. * through drm_mode_config_cleanup(). It can also be called at runtime
  339. * when a connector is being hot-unplugged for drivers that support
  340. * connector hotplugging (e.g. DisplayPort MST).
  341. */
  342. void (*destroy)(struct drm_connector *connector);
  343. /**
  344. * @atomic_duplicate_state:
  345. *
  346. * Duplicate the current atomic state for this connector and return it.
  347. * The core and helpers guarantee that any atomic state duplicated with
  348. * this hook and still owned by the caller (i.e. not transferred to the
  349. * driver by calling ->atomic_commit() from struct
  350. * &drm_mode_config_funcs) will be cleaned up by calling the
  351. * @atomic_destroy_state hook in this structure.
  352. *
  353. * Atomic drivers which don't subclass struct &drm_connector_state should use
  354. * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
  355. * state structure to extend it with driver-private state should use
  356. * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
  357. * duplicated in a consistent fashion across drivers.
  358. *
  359. * It is an error to call this hook before connector->state has been
  360. * initialized correctly.
  361. *
  362. * NOTE:
  363. *
  364. * If the duplicate state references refcounted resources this hook must
  365. * acquire a reference for each of them. The driver must release these
  366. * references again in @atomic_destroy_state.
  367. *
  368. * RETURNS:
  369. *
  370. * Duplicated atomic state or NULL when the allocation failed.
  371. */
  372. struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
  373. /**
  374. * @atomic_destroy_state:
  375. *
  376. * Destroy a state duplicated with @atomic_duplicate_state and release
  377. * or unreference all resources it references
  378. */
  379. void (*atomic_destroy_state)(struct drm_connector *connector,
  380. struct drm_connector_state *state);
  381. /**
  382. * @atomic_set_property:
  383. *
  384. * Decode a driver-private property value and store the decoded value
  385. * into the passed-in state structure. Since the atomic core decodes all
  386. * standardized properties (even for extensions beyond the core set of
  387. * properties which might not be implemented by all drivers) this
  388. * requires drivers to subclass the state structure.
  389. *
  390. * Such driver-private properties should really only be implemented for
  391. * truly hardware/vendor specific state. Instead it is preferred to
  392. * standardize atomic extension and decode the properties used to expose
  393. * such an extension in the core.
  394. *
  395. * Do not call this function directly, use
  396. * drm_atomic_connector_set_property() instead.
  397. *
  398. * This callback is optional if the driver does not support any
  399. * driver-private atomic properties.
  400. *
  401. * NOTE:
  402. *
  403. * This function is called in the state assembly phase of atomic
  404. * modesets, which can be aborted for any reason (including on
  405. * userspace's request to just check whether a configuration would be
  406. * possible). Drivers MUST NOT touch any persistent state (hardware or
  407. * software) or data structures except the passed in @state parameter.
  408. *
  409. * Also since userspace controls in which order properties are set this
  410. * function must not do any input validation (since the state update is
  411. * incomplete and hence likely inconsistent). Instead any such input
  412. * validation must be done in the various atomic_check callbacks.
  413. *
  414. * RETURNS:
  415. *
  416. * 0 if the property has been found, -EINVAL if the property isn't
  417. * implemented by the driver (which shouldn't ever happen, the core only
  418. * asks for properties attached to this connector). No other validation
  419. * is allowed by the driver. The core already checks that the property
  420. * value is within the range (integer, valid enum value, ...) the driver
  421. * set when registering the property.
  422. */
  423. int (*atomic_set_property)(struct drm_connector *connector,
  424. struct drm_connector_state *state,
  425. struct drm_property *property,
  426. uint64_t val);
  427. /**
  428. * @atomic_get_property:
  429. *
  430. * Reads out the decoded driver-private property. This is used to
  431. * implement the GETCONNECTOR IOCTL.
  432. *
  433. * Do not call this function directly, use
  434. * drm_atomic_connector_get_property() instead.
  435. *
  436. * This callback is optional if the driver does not support any
  437. * driver-private atomic properties.
  438. *
  439. * RETURNS:
  440. *
  441. * 0 on success, -EINVAL if the property isn't implemented by the
  442. * driver (which shouldn't ever happen, the core only asks for
  443. * properties attached to this connector).
  444. */
  445. int (*atomic_get_property)(struct drm_connector *connector,
  446. const struct drm_connector_state *state,
  447. struct drm_property *property,
  448. uint64_t *val);
  449. };
  450. /* mode specified on the command line */
  451. struct drm_cmdline_mode {
  452. bool specified;
  453. bool refresh_specified;
  454. bool bpp_specified;
  455. int xres, yres;
  456. int bpp;
  457. int refresh;
  458. bool rb;
  459. bool interlace;
  460. bool cvt;
  461. bool margins;
  462. enum drm_connector_force force;
  463. };
  464. /**
  465. * struct drm_connector - central DRM connector control structure
  466. * @dev: parent DRM device
  467. * @kdev: kernel device for sysfs attributes
  468. * @attr: sysfs attributes
  469. * @head: list management
  470. * @base: base KMS object
  471. * @name: human readable name, can be overwritten by the driver
  472. * @connector_type: one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
  473. * @connector_type_id: index into connector type enum
  474. * @interlace_allowed: can this connector handle interlaced modes?
  475. * @doublescan_allowed: can this connector handle doublescan?
  476. * @stereo_allowed: can this connector handle stereo modes?
  477. * @modes: modes available on this connector (from fill_modes() + user)
  478. * @status: one of the drm_connector_status enums (connected, not, or unknown)
  479. * @probed_modes: list of modes derived directly from the display
  480. * @funcs: connector control functions
  481. * @edid_blob_ptr: DRM property containing EDID if present
  482. * @properties: property tracking for this connector
  483. * @dpms: current dpms state
  484. * @helper_private: mid-layer private data
  485. * @cmdline_mode: mode line parsed from the kernel cmdline for this connector
  486. * @force: a DRM_FORCE_<foo> state for forced mode sets
  487. * @override_edid: has the EDID been overwritten through debugfs for testing?
  488. * @encoder_ids: valid encoders for this connector
  489. * @encoder: encoder driving this connector, if any
  490. * @eld: EDID-like data, if present
  491. * @latency_present: AV delay info from ELD, if found
  492. * @video_latency: video latency info from ELD, if found
  493. * @audio_latency: audio latency info from ELD, if found
  494. * @null_edid_counter: track sinks that give us all zeros for the EDID
  495. * @bad_edid_counter: track sinks that give us an EDID with invalid checksum
  496. * @edid_corrupt: indicates whether the last read EDID was corrupt
  497. * @debugfs_entry: debugfs directory for this connector
  498. * @state: current atomic state for this connector
  499. * @has_tile: is this connector connected to a tiled monitor
  500. * @tile_group: tile group for the connected monitor
  501. * @tile_is_single_monitor: whether the tile is one monitor housing
  502. * @num_h_tile: number of horizontal tiles in the tile group
  503. * @num_v_tile: number of vertical tiles in the tile group
  504. * @tile_h_loc: horizontal location of this tile
  505. * @tile_v_loc: vertical location of this tile
  506. * @tile_h_size: horizontal size of this tile.
  507. * @tile_v_size: vertical size of this tile.
  508. *
  509. * Each connector may be connected to one or more CRTCs, or may be clonable by
  510. * another connector if they can share a CRTC. Each connector also has a specific
  511. * position in the broader display (referred to as a 'screen' though it could
  512. * span multiple monitors).
  513. */
  514. struct drm_connector {
  515. struct drm_device *dev;
  516. struct device *kdev;
  517. struct device_attribute *attr;
  518. struct list_head head;
  519. struct drm_mode_object base;
  520. char *name;
  521. /**
  522. * @mutex: Lock for general connector state, but currently only protects
  523. * @registered. Most of the connector state is still protected by the
  524. * mutex in &drm_mode_config.
  525. */
  526. struct mutex mutex;
  527. /**
  528. * @index: Compacted connector index, which matches the position inside
  529. * the mode_config.list for drivers not supporting hot-add/removing. Can
  530. * be used as an array index. It is invariant over the lifetime of the
  531. * connector.
  532. */
  533. unsigned index;
  534. int connector_type;
  535. int connector_type_id;
  536. bool interlace_allowed;
  537. bool doublescan_allowed;
  538. bool stereo_allowed;
  539. /**
  540. * @registered: Is this connector exposed (registered) with userspace?
  541. * Protected by @mutex.
  542. */
  543. bool registered;
  544. struct list_head modes; /* list of modes on this connector */
  545. enum drm_connector_status status;
  546. /* these are modes added by probing with DDC or the BIOS */
  547. struct list_head probed_modes;
  548. /**
  549. * @display_info: Display information is filled from EDID information
  550. * when a display is detected. For non hot-pluggable displays such as
  551. * flat panels in embedded systems, the driver should initialize the
  552. * display_info.width_mm and display_info.height_mm fields with the
  553. * physical size of the display.
  554. */
  555. struct drm_display_info display_info;
  556. const struct drm_connector_funcs *funcs;
  557. struct drm_property_blob *edid_blob_ptr;
  558. struct drm_object_properties properties;
  559. /**
  560. * @path_blob_ptr:
  561. *
  562. * DRM blob property data for the DP MST path property.
  563. */
  564. struct drm_property_blob *path_blob_ptr;
  565. /**
  566. * @tile_blob_ptr:
  567. *
  568. * DRM blob property data for the tile property (used mostly by DP MST).
  569. * This is meant for screens which are driven through separate display
  570. * pipelines represented by &drm_crtc, which might not be running with
  571. * genlocked clocks. For tiled panels which are genlocked, like
  572. * dual-link LVDS or dual-link DSI, the driver should try to not expose
  573. * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
  574. */
  575. struct drm_property_blob *tile_blob_ptr;
  576. /* should we poll this connector for connects and disconnects */
  577. /* hot plug detectable */
  578. #define DRM_CONNECTOR_POLL_HPD (1 << 0)
  579. /* poll for connections */
  580. #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
  581. /* can cleanly poll for disconnections without flickering the screen */
  582. /* DACs should rarely do this without a lot of testing */
  583. #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
  584. /**
  585. * @polled:
  586. *
  587. * Connector polling mode, a combination of
  588. *
  589. * DRM_CONNECTOR_POLL_HPD
  590. * The connector generates hotplug events and doesn't need to be
  591. * periodically polled. The CONNECT and DISCONNECT flags must not
  592. * be set together with the HPD flag.
  593. *
  594. * DRM_CONNECTOR_POLL_CONNECT
  595. * Periodically poll the connector for connection.
  596. *
  597. * DRM_CONNECTOR_POLL_DISCONNECT
  598. * Periodically poll the connector for disconnection.
  599. *
  600. * Set to 0 for connectors that don't support connection status
  601. * discovery.
  602. */
  603. uint8_t polled;
  604. /* requested DPMS state */
  605. int dpms;
  606. const struct drm_connector_helper_funcs *helper_private;
  607. /* forced on connector */
  608. struct drm_cmdline_mode cmdline_mode;
  609. enum drm_connector_force force;
  610. bool override_edid;
  611. #define DRM_CONNECTOR_MAX_ENCODER 3
  612. uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
  613. struct drm_encoder *encoder; /* currently active encoder */
  614. #define MAX_ELD_BYTES 128
  615. /* EDID bits */
  616. uint8_t eld[MAX_ELD_BYTES];
  617. bool latency_present[2];
  618. int video_latency[2]; /* [0]: progressive, [1]: interlaced */
  619. int audio_latency[2];
  620. int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
  621. unsigned bad_edid_counter;
  622. /* Flag for raw EDID header corruption - used in Displayport
  623. * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6
  624. */
  625. bool edid_corrupt;
  626. struct dentry *debugfs_entry;
  627. struct drm_connector_state *state;
  628. /* DisplayID bits */
  629. bool has_tile;
  630. struct drm_tile_group *tile_group;
  631. bool tile_is_single_monitor;
  632. uint8_t num_h_tile, num_v_tile;
  633. uint8_t tile_h_loc, tile_v_loc;
  634. uint16_t tile_h_size, tile_v_size;
  635. };
  636. #define obj_to_connector(x) container_of(x, struct drm_connector, base)
  637. int drm_connector_init(struct drm_device *dev,
  638. struct drm_connector *connector,
  639. const struct drm_connector_funcs *funcs,
  640. int connector_type);
  641. int drm_connector_register(struct drm_connector *connector);
  642. void drm_connector_unregister(struct drm_connector *connector);
  643. int drm_mode_connector_attach_encoder(struct drm_connector *connector,
  644. struct drm_encoder *encoder);
  645. void drm_connector_cleanup(struct drm_connector *connector);
  646. static inline unsigned drm_connector_index(struct drm_connector *connector)
  647. {
  648. return connector->index;
  649. }
  650. /**
  651. * drm_connector_lookup - lookup connector object
  652. * @dev: DRM device
  653. * @id: connector object id
  654. *
  655. * This function looks up the connector object specified by id
  656. * add takes a reference to it.
  657. */
  658. static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
  659. uint32_t id)
  660. {
  661. struct drm_mode_object *mo;
  662. mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR);
  663. return mo ? obj_to_connector(mo) : NULL;
  664. }
  665. /**
  666. * drm_connector_reference - incr the connector refcnt
  667. * @connector: connector
  668. *
  669. * This function increments the connector's refcount.
  670. */
  671. static inline void drm_connector_reference(struct drm_connector *connector)
  672. {
  673. drm_mode_object_reference(&connector->base);
  674. }
  675. /**
  676. * drm_connector_unreference - unref a connector
  677. * @connector: connector to unref
  678. *
  679. * This function decrements the connector's refcount and frees it if it drops to zero.
  680. */
  681. static inline void drm_connector_unreference(struct drm_connector *connector)
  682. {
  683. drm_mode_object_unreference(&connector->base);
  684. }
  685. const char *drm_get_connector_status_name(enum drm_connector_status status);
  686. const char *drm_get_subpixel_order_name(enum subpixel_order order);
  687. const char *drm_get_dpms_name(int val);
  688. const char *drm_get_dvi_i_subconnector_name(int val);
  689. const char *drm_get_dvi_i_select_name(int val);
  690. const char *drm_get_tv_subconnector_name(int val);
  691. const char *drm_get_tv_select_name(int val);
  692. int drm_mode_create_dvi_i_properties(struct drm_device *dev);
  693. int drm_mode_create_tv_properties(struct drm_device *dev,
  694. unsigned int num_modes,
  695. const char * const modes[]);
  696. int drm_mode_create_scaling_mode_property(struct drm_device *dev);
  697. int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
  698. int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
  699. int drm_mode_connector_set_path_property(struct drm_connector *connector,
  700. const char *path);
  701. int drm_mode_connector_set_tile_property(struct drm_connector *connector);
  702. int drm_mode_connector_update_edid_property(struct drm_connector *connector,
  703. const struct edid *edid);
  704. /**
  705. * drm_for_each_connector - iterate over all connectors
  706. * @connector: the loop cursor
  707. * @dev: the DRM device
  708. *
  709. * Iterate over all connectors of @dev.
  710. */
  711. #define drm_for_each_connector(connector, dev) \
  712. for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \
  713. connector = list_first_entry(&(dev)->mode_config.connector_list, \
  714. struct drm_connector, head); \
  715. &connector->head != (&(dev)->mode_config.connector_list); \
  716. connector = list_next_entry(connector, head))
  717. #endif