drm_connector.h 30 KB

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