omapdss.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /*
  2. * Copyright (C) 2016 Texas Instruments
  3. * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __OMAP_DRM_DSS_H
  18. #define __OMAP_DRM_DSS_H
  19. #include <linux/list.h>
  20. #include <linux/kobject.h>
  21. #include <linux/device.h>
  22. #include <linux/interrupt.h>
  23. #include <video/videomode.h>
  24. #include <linux/platform_data/omapdss.h>
  25. #include <uapi/drm/drm_mode.h>
  26. #define DISPC_IRQ_FRAMEDONE (1 << 0)
  27. #define DISPC_IRQ_VSYNC (1 << 1)
  28. #define DISPC_IRQ_EVSYNC_EVEN (1 << 2)
  29. #define DISPC_IRQ_EVSYNC_ODD (1 << 3)
  30. #define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4)
  31. #define DISPC_IRQ_PROG_LINE_NUM (1 << 5)
  32. #define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6)
  33. #define DISPC_IRQ_GFX_END_WIN (1 << 7)
  34. #define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8)
  35. #define DISPC_IRQ_OCP_ERR (1 << 9)
  36. #define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10)
  37. #define DISPC_IRQ_VID1_END_WIN (1 << 11)
  38. #define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12)
  39. #define DISPC_IRQ_VID2_END_WIN (1 << 13)
  40. #define DISPC_IRQ_SYNC_LOST (1 << 14)
  41. #define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15)
  42. #define DISPC_IRQ_WAKEUP (1 << 16)
  43. #define DISPC_IRQ_SYNC_LOST2 (1 << 17)
  44. #define DISPC_IRQ_VSYNC2 (1 << 18)
  45. #define DISPC_IRQ_VID3_END_WIN (1 << 19)
  46. #define DISPC_IRQ_VID3_FIFO_UNDERFLOW (1 << 20)
  47. #define DISPC_IRQ_ACBIAS_COUNT_STAT2 (1 << 21)
  48. #define DISPC_IRQ_FRAMEDONE2 (1 << 22)
  49. #define DISPC_IRQ_FRAMEDONEWB (1 << 23)
  50. #define DISPC_IRQ_FRAMEDONETV (1 << 24)
  51. #define DISPC_IRQ_WBBUFFEROVERFLOW (1 << 25)
  52. #define DISPC_IRQ_WBUNCOMPLETEERROR (1 << 26)
  53. #define DISPC_IRQ_SYNC_LOST3 (1 << 27)
  54. #define DISPC_IRQ_VSYNC3 (1 << 28)
  55. #define DISPC_IRQ_ACBIAS_COUNT_STAT3 (1 << 29)
  56. #define DISPC_IRQ_FRAMEDONE3 (1 << 30)
  57. struct omap_dss_device;
  58. struct dss_lcd_mgr_config;
  59. struct snd_aes_iec958;
  60. struct snd_cea_861_aud_if;
  61. struct hdmi_avi_infoframe;
  62. enum omap_display_type {
  63. OMAP_DISPLAY_TYPE_NONE = 0,
  64. OMAP_DISPLAY_TYPE_DPI = 1 << 0,
  65. OMAP_DISPLAY_TYPE_DBI = 1 << 1,
  66. OMAP_DISPLAY_TYPE_SDI = 1 << 2,
  67. OMAP_DISPLAY_TYPE_DSI = 1 << 3,
  68. OMAP_DISPLAY_TYPE_VENC = 1 << 4,
  69. OMAP_DISPLAY_TYPE_HDMI = 1 << 5,
  70. OMAP_DISPLAY_TYPE_DVI = 1 << 6,
  71. };
  72. enum omap_plane_id {
  73. OMAP_DSS_GFX = 0,
  74. OMAP_DSS_VIDEO1 = 1,
  75. OMAP_DSS_VIDEO2 = 2,
  76. OMAP_DSS_VIDEO3 = 3,
  77. OMAP_DSS_WB = 4,
  78. };
  79. enum omap_channel {
  80. OMAP_DSS_CHANNEL_LCD = 0,
  81. OMAP_DSS_CHANNEL_DIGIT = 1,
  82. OMAP_DSS_CHANNEL_LCD2 = 2,
  83. OMAP_DSS_CHANNEL_LCD3 = 3,
  84. OMAP_DSS_CHANNEL_WB = 4,
  85. };
  86. enum omap_color_mode {
  87. OMAP_DSS_COLOR_CLUT1 = 1 << 0, /* BITMAP 1 */
  88. OMAP_DSS_COLOR_CLUT2 = 1 << 1, /* BITMAP 2 */
  89. OMAP_DSS_COLOR_CLUT4 = 1 << 2, /* BITMAP 4 */
  90. OMAP_DSS_COLOR_CLUT8 = 1 << 3, /* BITMAP 8 */
  91. OMAP_DSS_COLOR_RGB12U = 1 << 4, /* RGB12, 16-bit container */
  92. OMAP_DSS_COLOR_ARGB16 = 1 << 5, /* ARGB16 */
  93. OMAP_DSS_COLOR_RGB16 = 1 << 6, /* RGB16 */
  94. OMAP_DSS_COLOR_RGB24U = 1 << 7, /* RGB24, 32-bit container */
  95. OMAP_DSS_COLOR_RGB24P = 1 << 8, /* RGB24, 24-bit container */
  96. OMAP_DSS_COLOR_YUV2 = 1 << 9, /* YUV2 4:2:2 co-sited */
  97. OMAP_DSS_COLOR_UYVY = 1 << 10, /* UYVY 4:2:2 co-sited */
  98. OMAP_DSS_COLOR_ARGB32 = 1 << 11, /* ARGB32 */
  99. OMAP_DSS_COLOR_RGBA32 = 1 << 12, /* RGBA32 */
  100. OMAP_DSS_COLOR_RGBX32 = 1 << 13, /* RGBx32 */
  101. OMAP_DSS_COLOR_NV12 = 1 << 14, /* NV12 format: YUV 4:2:0 */
  102. OMAP_DSS_COLOR_RGBA16 = 1 << 15, /* RGBA16 - 4444 */
  103. OMAP_DSS_COLOR_RGBX16 = 1 << 16, /* RGBx16 - 4444 */
  104. OMAP_DSS_COLOR_ARGB16_1555 = 1 << 17, /* ARGB16 - 1555 */
  105. OMAP_DSS_COLOR_XRGB16_1555 = 1 << 18, /* xRGB16 - 1555 */
  106. };
  107. enum omap_dss_load_mode {
  108. OMAP_DSS_LOAD_CLUT_AND_FRAME = 0,
  109. OMAP_DSS_LOAD_CLUT_ONLY = 1,
  110. OMAP_DSS_LOAD_FRAME_ONLY = 2,
  111. OMAP_DSS_LOAD_CLUT_ONCE_FRAME = 3,
  112. };
  113. enum omap_dss_trans_key_type {
  114. OMAP_DSS_COLOR_KEY_GFX_DST = 0,
  115. OMAP_DSS_COLOR_KEY_VID_SRC = 1,
  116. };
  117. enum omap_dss_signal_level {
  118. OMAPDSS_SIG_ACTIVE_LOW,
  119. OMAPDSS_SIG_ACTIVE_HIGH,
  120. };
  121. enum omap_dss_signal_edge {
  122. OMAPDSS_DRIVE_SIG_FALLING_EDGE,
  123. OMAPDSS_DRIVE_SIG_RISING_EDGE,
  124. };
  125. enum omap_dss_venc_type {
  126. OMAP_DSS_VENC_TYPE_COMPOSITE,
  127. OMAP_DSS_VENC_TYPE_SVIDEO,
  128. };
  129. enum omap_dss_dsi_pixel_format {
  130. OMAP_DSS_DSI_FMT_RGB888,
  131. OMAP_DSS_DSI_FMT_RGB666,
  132. OMAP_DSS_DSI_FMT_RGB666_PACKED,
  133. OMAP_DSS_DSI_FMT_RGB565,
  134. };
  135. enum omap_dss_dsi_mode {
  136. OMAP_DSS_DSI_CMD_MODE = 0,
  137. OMAP_DSS_DSI_VIDEO_MODE,
  138. };
  139. enum omap_display_caps {
  140. OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE = 1 << 0,
  141. OMAP_DSS_DISPLAY_CAP_TEAR_ELIM = 1 << 1,
  142. };
  143. enum omap_dss_display_state {
  144. OMAP_DSS_DISPLAY_DISABLED = 0,
  145. OMAP_DSS_DISPLAY_ACTIVE,
  146. };
  147. enum omap_dss_rotation_type {
  148. OMAP_DSS_ROT_DMA = 1 << 0,
  149. OMAP_DSS_ROT_VRFB = 1 << 1,
  150. OMAP_DSS_ROT_TILER = 1 << 2,
  151. };
  152. /* clockwise rotation angle */
  153. enum omap_dss_rotation_angle {
  154. OMAP_DSS_ROT_0 = 0,
  155. OMAP_DSS_ROT_90 = 1,
  156. OMAP_DSS_ROT_180 = 2,
  157. OMAP_DSS_ROT_270 = 3,
  158. };
  159. enum omap_overlay_caps {
  160. OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
  161. OMAP_DSS_OVL_CAP_GLOBAL_ALPHA = 1 << 1,
  162. OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA = 1 << 2,
  163. OMAP_DSS_OVL_CAP_ZORDER = 1 << 3,
  164. OMAP_DSS_OVL_CAP_POS = 1 << 4,
  165. OMAP_DSS_OVL_CAP_REPLICATION = 1 << 5,
  166. };
  167. enum omap_dss_clk_source {
  168. OMAP_DSS_CLK_SRC_FCK = 0, /* OMAP2/3: DSS1_ALWON_FCLK
  169. * OMAP4: DSS_FCLK */
  170. OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, /* OMAP3: DSI1_PLL_FCLK
  171. * OMAP4: PLL1_CLK1 */
  172. OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, /* OMAP3: DSI2_PLL_FCLK
  173. * OMAP4: PLL1_CLK2 */
  174. OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC, /* OMAP4: PLL2_CLK1 */
  175. OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI, /* OMAP4: PLL2_CLK2 */
  176. };
  177. enum omap_hdmi_flags {
  178. OMAP_HDMI_SDA_SCL_EXTERNAL_PULLUP = 1 << 0,
  179. };
  180. enum omap_dss_output_id {
  181. OMAP_DSS_OUTPUT_DPI = 1 << 0,
  182. OMAP_DSS_OUTPUT_DBI = 1 << 1,
  183. OMAP_DSS_OUTPUT_SDI = 1 << 2,
  184. OMAP_DSS_OUTPUT_DSI1 = 1 << 3,
  185. OMAP_DSS_OUTPUT_DSI2 = 1 << 4,
  186. OMAP_DSS_OUTPUT_VENC = 1 << 5,
  187. OMAP_DSS_OUTPUT_HDMI = 1 << 6,
  188. };
  189. /* DSI */
  190. enum omap_dss_dsi_trans_mode {
  191. /* Sync Pulses: both sync start and end packets sent */
  192. OMAP_DSS_DSI_PULSE_MODE,
  193. /* Sync Events: only sync start packets sent */
  194. OMAP_DSS_DSI_EVENT_MODE,
  195. /* Burst: only sync start packets sent, pixels are time compressed */
  196. OMAP_DSS_DSI_BURST_MODE,
  197. };
  198. struct omap_dss_dsi_videomode_timings {
  199. unsigned long hsclk;
  200. unsigned ndl;
  201. unsigned bitspp;
  202. /* pixels */
  203. u16 hact;
  204. /* lines */
  205. u16 vact;
  206. /* DSI video mode blanking data */
  207. /* Unit: byte clock cycles */
  208. u16 hss;
  209. u16 hsa;
  210. u16 hse;
  211. u16 hfp;
  212. u16 hbp;
  213. /* Unit: line clocks */
  214. u16 vsa;
  215. u16 vfp;
  216. u16 vbp;
  217. /* DSI blanking modes */
  218. int blanking_mode;
  219. int hsa_blanking_mode;
  220. int hbp_blanking_mode;
  221. int hfp_blanking_mode;
  222. enum omap_dss_dsi_trans_mode trans_mode;
  223. bool ddr_clk_always_on;
  224. int window_sync;
  225. };
  226. struct omap_dss_dsi_config {
  227. enum omap_dss_dsi_mode mode;
  228. enum omap_dss_dsi_pixel_format pixel_format;
  229. const struct videomode *vm;
  230. unsigned long hs_clk_min, hs_clk_max;
  231. unsigned long lp_clk_min, lp_clk_max;
  232. bool ddr_clk_always_on;
  233. enum omap_dss_dsi_trans_mode trans_mode;
  234. };
  235. /* Hardcoded videomodes for tv. Venc only uses these to
  236. * identify the mode, and does not actually use the configs
  237. * itself. However, the configs should be something that
  238. * a normal monitor can also show */
  239. extern const struct videomode omap_dss_pal_vm;
  240. extern const struct videomode omap_dss_ntsc_vm;
  241. struct omap_dss_cpr_coefs {
  242. s16 rr, rg, rb;
  243. s16 gr, gg, gb;
  244. s16 br, bg, bb;
  245. };
  246. struct omap_overlay_info {
  247. dma_addr_t paddr;
  248. dma_addr_t p_uv_addr; /* for NV12 format */
  249. u16 screen_width;
  250. u16 width;
  251. u16 height;
  252. enum omap_color_mode color_mode;
  253. u8 rotation;
  254. enum omap_dss_rotation_type rotation_type;
  255. bool mirror;
  256. u16 pos_x;
  257. u16 pos_y;
  258. u16 out_width; /* if 0, out_width == width */
  259. u16 out_height; /* if 0, out_height == height */
  260. u8 global_alpha;
  261. u8 pre_mult_alpha;
  262. u8 zorder;
  263. };
  264. struct omap_overlay_manager_info {
  265. u32 default_color;
  266. enum omap_dss_trans_key_type trans_key_type;
  267. u32 trans_key;
  268. bool trans_enabled;
  269. bool partial_alpha_enabled;
  270. bool cpr_enable;
  271. struct omap_dss_cpr_coefs cpr_coefs;
  272. };
  273. /* 22 pins means 1 clk lane and 10 data lanes */
  274. #define OMAP_DSS_MAX_DSI_PINS 22
  275. struct omap_dsi_pin_config {
  276. int num_pins;
  277. /*
  278. * pin numbers in the following order:
  279. * clk+, clk-
  280. * data1+, data1-
  281. * data2+, data2-
  282. * ...
  283. */
  284. int pins[OMAP_DSS_MAX_DSI_PINS];
  285. };
  286. struct omap_dss_writeback_info {
  287. u32 paddr;
  288. u32 p_uv_addr;
  289. u16 buf_width;
  290. u16 width;
  291. u16 height;
  292. enum omap_color_mode color_mode;
  293. u8 rotation;
  294. enum omap_dss_rotation_type rotation_type;
  295. bool mirror;
  296. u8 pre_mult_alpha;
  297. };
  298. struct omapdss_dpi_ops {
  299. int (*connect)(struct omap_dss_device *dssdev,
  300. struct omap_dss_device *dst);
  301. void (*disconnect)(struct omap_dss_device *dssdev,
  302. struct omap_dss_device *dst);
  303. int (*enable)(struct omap_dss_device *dssdev);
  304. void (*disable)(struct omap_dss_device *dssdev);
  305. int (*check_timings)(struct omap_dss_device *dssdev,
  306. struct videomode *vm);
  307. void (*set_timings)(struct omap_dss_device *dssdev,
  308. struct videomode *vm);
  309. void (*get_timings)(struct omap_dss_device *dssdev,
  310. struct videomode *vm);
  311. };
  312. struct omapdss_sdi_ops {
  313. int (*connect)(struct omap_dss_device *dssdev,
  314. struct omap_dss_device *dst);
  315. void (*disconnect)(struct omap_dss_device *dssdev,
  316. struct omap_dss_device *dst);
  317. int (*enable)(struct omap_dss_device *dssdev);
  318. void (*disable)(struct omap_dss_device *dssdev);
  319. int (*check_timings)(struct omap_dss_device *dssdev,
  320. struct videomode *vm);
  321. void (*set_timings)(struct omap_dss_device *dssdev,
  322. struct videomode *vm);
  323. void (*get_timings)(struct omap_dss_device *dssdev,
  324. struct videomode *vm);
  325. };
  326. struct omapdss_dvi_ops {
  327. int (*connect)(struct omap_dss_device *dssdev,
  328. struct omap_dss_device *dst);
  329. void (*disconnect)(struct omap_dss_device *dssdev,
  330. struct omap_dss_device *dst);
  331. int (*enable)(struct omap_dss_device *dssdev);
  332. void (*disable)(struct omap_dss_device *dssdev);
  333. int (*check_timings)(struct omap_dss_device *dssdev,
  334. struct videomode *vm);
  335. void (*set_timings)(struct omap_dss_device *dssdev,
  336. struct videomode *vm);
  337. void (*get_timings)(struct omap_dss_device *dssdev,
  338. struct videomode *vm);
  339. };
  340. struct omapdss_atv_ops {
  341. int (*connect)(struct omap_dss_device *dssdev,
  342. struct omap_dss_device *dst);
  343. void (*disconnect)(struct omap_dss_device *dssdev,
  344. struct omap_dss_device *dst);
  345. int (*enable)(struct omap_dss_device *dssdev);
  346. void (*disable)(struct omap_dss_device *dssdev);
  347. int (*check_timings)(struct omap_dss_device *dssdev,
  348. struct videomode *vm);
  349. void (*set_timings)(struct omap_dss_device *dssdev,
  350. struct videomode *vm);
  351. void (*get_timings)(struct omap_dss_device *dssdev,
  352. struct videomode *vm);
  353. int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
  354. u32 (*get_wss)(struct omap_dss_device *dssdev);
  355. };
  356. struct omapdss_hdmi_ops {
  357. int (*connect)(struct omap_dss_device *dssdev,
  358. struct omap_dss_device *dst);
  359. void (*disconnect)(struct omap_dss_device *dssdev,
  360. struct omap_dss_device *dst);
  361. int (*enable)(struct omap_dss_device *dssdev);
  362. void (*disable)(struct omap_dss_device *dssdev);
  363. int (*check_timings)(struct omap_dss_device *dssdev,
  364. struct videomode *vm);
  365. void (*set_timings)(struct omap_dss_device *dssdev,
  366. struct videomode *vm);
  367. void (*get_timings)(struct omap_dss_device *dssdev,
  368. struct videomode *vm);
  369. int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
  370. bool (*detect)(struct omap_dss_device *dssdev);
  371. int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
  372. int (*set_infoframe)(struct omap_dss_device *dssdev,
  373. const struct hdmi_avi_infoframe *avi);
  374. };
  375. struct omapdss_dsi_ops {
  376. int (*connect)(struct omap_dss_device *dssdev,
  377. struct omap_dss_device *dst);
  378. void (*disconnect)(struct omap_dss_device *dssdev,
  379. struct omap_dss_device *dst);
  380. int (*enable)(struct omap_dss_device *dssdev);
  381. void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
  382. bool enter_ulps);
  383. /* bus configuration */
  384. int (*set_config)(struct omap_dss_device *dssdev,
  385. const struct omap_dss_dsi_config *cfg);
  386. int (*configure_pins)(struct omap_dss_device *dssdev,
  387. const struct omap_dsi_pin_config *pin_cfg);
  388. void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
  389. bool enable);
  390. int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
  391. int (*update)(struct omap_dss_device *dssdev, int channel,
  392. void (*callback)(int, void *), void *data);
  393. void (*bus_lock)(struct omap_dss_device *dssdev);
  394. void (*bus_unlock)(struct omap_dss_device *dssdev);
  395. int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
  396. void (*disable_video_output)(struct omap_dss_device *dssdev,
  397. int channel);
  398. int (*request_vc)(struct omap_dss_device *dssdev, int *channel);
  399. int (*set_vc_id)(struct omap_dss_device *dssdev, int channel,
  400. int vc_id);
  401. void (*release_vc)(struct omap_dss_device *dssdev, int channel);
  402. /* data transfer */
  403. int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
  404. u8 *data, int len);
  405. int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
  406. u8 *data, int len);
  407. int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
  408. u8 *data, int len);
  409. int (*gen_write)(struct omap_dss_device *dssdev, int channel,
  410. u8 *data, int len);
  411. int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
  412. u8 *data, int len);
  413. int (*gen_read)(struct omap_dss_device *dssdev, int channel,
  414. u8 *reqdata, int reqlen,
  415. u8 *data, int len);
  416. int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
  417. int (*set_max_rx_packet_size)(struct omap_dss_device *dssdev,
  418. int channel, u16 plen);
  419. };
  420. struct omap_dss_device {
  421. struct kobject kobj;
  422. struct device *dev;
  423. struct module *owner;
  424. struct list_head panel_list;
  425. /* alias in the form of "display%d" */
  426. char alias[16];
  427. enum omap_display_type type;
  428. enum omap_display_type output_type;
  429. struct {
  430. struct videomode vm;
  431. enum omap_dss_dsi_pixel_format dsi_pix_fmt;
  432. enum omap_dss_dsi_mode dsi_mode;
  433. } panel;
  434. const char *name;
  435. struct omap_dss_driver *driver;
  436. union {
  437. const struct omapdss_dpi_ops *dpi;
  438. const struct omapdss_sdi_ops *sdi;
  439. const struct omapdss_dvi_ops *dvi;
  440. const struct omapdss_hdmi_ops *hdmi;
  441. const struct omapdss_atv_ops *atv;
  442. const struct omapdss_dsi_ops *dsi;
  443. } ops;
  444. /* helper variable for driver suspend/resume */
  445. bool activate_after_resume;
  446. enum omap_display_caps caps;
  447. struct omap_dss_device *src;
  448. enum omap_dss_display_state state;
  449. /* OMAP DSS output specific fields */
  450. struct list_head list;
  451. /* DISPC channel for this output */
  452. enum omap_channel dispc_channel;
  453. bool dispc_channel_connected;
  454. /* output instance */
  455. enum omap_dss_output_id id;
  456. /* the port number in the DT node */
  457. int port_num;
  458. /* dynamic fields */
  459. struct omap_dss_device *dst;
  460. };
  461. struct omap_dss_driver {
  462. int (*probe)(struct omap_dss_device *);
  463. void (*remove)(struct omap_dss_device *);
  464. int (*connect)(struct omap_dss_device *dssdev);
  465. void (*disconnect)(struct omap_dss_device *dssdev);
  466. int (*enable)(struct omap_dss_device *display);
  467. void (*disable)(struct omap_dss_device *display);
  468. int (*run_test)(struct omap_dss_device *display, int test);
  469. int (*update)(struct omap_dss_device *dssdev,
  470. u16 x, u16 y, u16 w, u16 h);
  471. int (*sync)(struct omap_dss_device *dssdev);
  472. int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
  473. int (*get_te)(struct omap_dss_device *dssdev);
  474. u8 (*get_rotate)(struct omap_dss_device *dssdev);
  475. int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
  476. bool (*get_mirror)(struct omap_dss_device *dssdev);
  477. int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
  478. int (*memory_read)(struct omap_dss_device *dssdev,
  479. void *buf, size_t size,
  480. u16 x, u16 y, u16 w, u16 h);
  481. int (*check_timings)(struct omap_dss_device *dssdev,
  482. struct videomode *vm);
  483. void (*set_timings)(struct omap_dss_device *dssdev,
  484. struct videomode *vm);
  485. void (*get_timings)(struct omap_dss_device *dssdev,
  486. struct videomode *vm);
  487. int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
  488. u32 (*get_wss)(struct omap_dss_device *dssdev);
  489. int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
  490. bool (*detect)(struct omap_dss_device *dssdev);
  491. int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
  492. int (*set_hdmi_infoframe)(struct omap_dss_device *dssdev,
  493. const struct hdmi_avi_infoframe *avi);
  494. };
  495. enum omapdss_version omapdss_get_version(void);
  496. bool omapdss_is_initialized(void);
  497. int omap_dss_register_driver(struct omap_dss_driver *);
  498. void omap_dss_unregister_driver(struct omap_dss_driver *);
  499. int omapdss_register_display(struct omap_dss_device *dssdev);
  500. void omapdss_unregister_display(struct omap_dss_device *dssdev);
  501. struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
  502. void omap_dss_put_device(struct omap_dss_device *dssdev);
  503. #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
  504. struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
  505. struct omap_dss_device *omap_dss_find_device(void *data,
  506. int (*match)(struct omap_dss_device *dssdev, void *data));
  507. int dss_feat_get_num_mgrs(void);
  508. int dss_feat_get_num_ovls(void);
  509. enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane_id plane);
  510. int omap_dss_get_num_overlay_managers(void);
  511. int omap_dss_get_num_overlays(void);
  512. int omapdss_register_output(struct omap_dss_device *output);
  513. void omapdss_unregister_output(struct omap_dss_device *output);
  514. struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
  515. struct omap_dss_device *omap_dss_find_output(const char *name);
  516. struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port);
  517. int omapdss_output_set_device(struct omap_dss_device *out,
  518. struct omap_dss_device *dssdev);
  519. int omapdss_output_unset_device(struct omap_dss_device *out);
  520. struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev);
  521. void omapdss_default_get_timings(struct omap_dss_device *dssdev,
  522. struct videomode *vm);
  523. typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
  524. int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
  525. int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
  526. int omapdss_compat_init(void);
  527. void omapdss_compat_uninit(void);
  528. static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
  529. {
  530. return dssdev->src;
  531. }
  532. static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
  533. {
  534. return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
  535. }
  536. struct omap_dss_device *
  537. omapdss_of_find_source_for_first_ep(struct device_node *node);
  538. void omapdss_set_is_initialized(bool set);
  539. struct device_node *dss_of_port_get_parent_device(struct device_node *port);
  540. u32 dss_of_port_get_port_number(struct device_node *port);
  541. struct dss_mgr_ops {
  542. int (*connect)(enum omap_channel channel,
  543. struct omap_dss_device *dst);
  544. void (*disconnect)(enum omap_channel channel,
  545. struct omap_dss_device *dst);
  546. void (*start_update)(enum omap_channel channel);
  547. int (*enable)(enum omap_channel channel);
  548. void (*disable)(enum omap_channel channel);
  549. void (*set_timings)(enum omap_channel channel,
  550. const struct videomode *vm);
  551. void (*set_lcd_config)(enum omap_channel channel,
  552. const struct dss_lcd_mgr_config *config);
  553. int (*register_framedone_handler)(enum omap_channel channel,
  554. void (*handler)(void *), void *data);
  555. void (*unregister_framedone_handler)(enum omap_channel channel,
  556. void (*handler)(void *), void *data);
  557. };
  558. int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
  559. void dss_uninstall_mgr_ops(void);
  560. int dss_mgr_connect(enum omap_channel channel,
  561. struct omap_dss_device *dst);
  562. void dss_mgr_disconnect(enum omap_channel channel,
  563. struct omap_dss_device *dst);
  564. void dss_mgr_set_timings(enum omap_channel channel,
  565. const struct videomode *vm);
  566. void dss_mgr_set_lcd_config(enum omap_channel channel,
  567. const struct dss_lcd_mgr_config *config);
  568. int dss_mgr_enable(enum omap_channel channel);
  569. void dss_mgr_disable(enum omap_channel channel);
  570. void dss_mgr_start_update(enum omap_channel channel);
  571. int dss_mgr_register_framedone_handler(enum omap_channel channel,
  572. void (*handler)(void *), void *data);
  573. void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
  574. void (*handler)(void *), void *data);
  575. /* dispc ops */
  576. struct dispc_ops {
  577. u32 (*read_irqstatus)(void);
  578. void (*clear_irqstatus)(u32 mask);
  579. void (*write_irqenable)(u32 mask);
  580. int (*request_irq)(irq_handler_t handler, void *dev_id);
  581. void (*free_irq)(void *dev_id);
  582. int (*runtime_get)(void);
  583. void (*runtime_put)(void);
  584. int (*get_num_ovls)(void);
  585. int (*get_num_mgrs)(void);
  586. void (*mgr_enable)(enum omap_channel channel, bool enable);
  587. bool (*mgr_is_enabled)(enum omap_channel channel);
  588. u32 (*mgr_get_vsync_irq)(enum omap_channel channel);
  589. u32 (*mgr_get_framedone_irq)(enum omap_channel channel);
  590. u32 (*mgr_get_sync_lost_irq)(enum omap_channel channel);
  591. bool (*mgr_go_busy)(enum omap_channel channel);
  592. void (*mgr_go)(enum omap_channel channel);
  593. void (*mgr_set_lcd_config)(enum omap_channel channel,
  594. const struct dss_lcd_mgr_config *config);
  595. void (*mgr_set_timings)(enum omap_channel channel,
  596. const struct videomode *vm);
  597. void (*mgr_setup)(enum omap_channel channel,
  598. const struct omap_overlay_manager_info *info);
  599. enum omap_dss_output_id (*mgr_get_supported_outputs)(enum omap_channel channel);
  600. u32 (*mgr_gamma_size)(enum omap_channel channel);
  601. void (*mgr_set_gamma)(enum omap_channel channel,
  602. const struct drm_color_lut *lut,
  603. unsigned int length);
  604. int (*ovl_enable)(enum omap_plane_id plane, bool enable);
  605. int (*ovl_setup)(enum omap_plane_id plane,
  606. const struct omap_overlay_info *oi,
  607. const struct videomode *vm, bool mem_to_mem,
  608. enum omap_channel channel);
  609. enum omap_color_mode (*ovl_get_color_modes)(enum omap_plane_id plane);
  610. };
  611. void dispc_set_ops(const struct dispc_ops *o);
  612. const struct dispc_ops *dispc_get_ops(void);
  613. bool omapdss_component_is_display(struct device_node *node);
  614. bool omapdss_component_is_output(struct device_node *node);
  615. bool omapdss_stack_is_ready(void);
  616. void omapdss_gather_components(struct device *dev);
  617. #endif /* __OMAP_DRM_DSS_H */