omapfb_dss.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2016 Texas Instruments, Inc.
  4. */
  5. #ifndef __OMAPFB_DSS_H
  6. #define __OMAPFB_DSS_H
  7. #include <linux/list.h>
  8. #include <linux/kobject.h>
  9. #include <linux/device.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/platform_data/omapdss.h>
  12. #include <video/videomode.h>
  13. #define DISPC_IRQ_FRAMEDONE (1 << 0)
  14. #define DISPC_IRQ_VSYNC (1 << 1)
  15. #define DISPC_IRQ_EVSYNC_EVEN (1 << 2)
  16. #define DISPC_IRQ_EVSYNC_ODD (1 << 3)
  17. #define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4)
  18. #define DISPC_IRQ_PROG_LINE_NUM (1 << 5)
  19. #define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6)
  20. #define DISPC_IRQ_GFX_END_WIN (1 << 7)
  21. #define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8)
  22. #define DISPC_IRQ_OCP_ERR (1 << 9)
  23. #define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10)
  24. #define DISPC_IRQ_VID1_END_WIN (1 << 11)
  25. #define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12)
  26. #define DISPC_IRQ_VID2_END_WIN (1 << 13)
  27. #define DISPC_IRQ_SYNC_LOST (1 << 14)
  28. #define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15)
  29. #define DISPC_IRQ_WAKEUP (1 << 16)
  30. #define DISPC_IRQ_SYNC_LOST2 (1 << 17)
  31. #define DISPC_IRQ_VSYNC2 (1 << 18)
  32. #define DISPC_IRQ_VID3_END_WIN (1 << 19)
  33. #define DISPC_IRQ_VID3_FIFO_UNDERFLOW (1 << 20)
  34. #define DISPC_IRQ_ACBIAS_COUNT_STAT2 (1 << 21)
  35. #define DISPC_IRQ_FRAMEDONE2 (1 << 22)
  36. #define DISPC_IRQ_FRAMEDONEWB (1 << 23)
  37. #define DISPC_IRQ_FRAMEDONETV (1 << 24)
  38. #define DISPC_IRQ_WBBUFFEROVERFLOW (1 << 25)
  39. #define DISPC_IRQ_WBUNCOMPLETEERROR (1 << 26)
  40. #define DISPC_IRQ_SYNC_LOST3 (1 << 27)
  41. #define DISPC_IRQ_VSYNC3 (1 << 28)
  42. #define DISPC_IRQ_ACBIAS_COUNT_STAT3 (1 << 29)
  43. #define DISPC_IRQ_FRAMEDONE3 (1 << 30)
  44. struct omap_dss_device;
  45. struct omap_overlay_manager;
  46. struct dss_lcd_mgr_config;
  47. struct snd_aes_iec958;
  48. struct snd_cea_861_aud_if;
  49. struct hdmi_avi_infoframe;
  50. enum omap_display_type {
  51. OMAP_DISPLAY_TYPE_NONE = 0,
  52. OMAP_DISPLAY_TYPE_DPI = 1 << 0,
  53. OMAP_DISPLAY_TYPE_DBI = 1 << 1,
  54. OMAP_DISPLAY_TYPE_SDI = 1 << 2,
  55. OMAP_DISPLAY_TYPE_DSI = 1 << 3,
  56. OMAP_DISPLAY_TYPE_VENC = 1 << 4,
  57. OMAP_DISPLAY_TYPE_HDMI = 1 << 5,
  58. OMAP_DISPLAY_TYPE_DVI = 1 << 6,
  59. };
  60. enum omap_plane {
  61. OMAP_DSS_GFX = 0,
  62. OMAP_DSS_VIDEO1 = 1,
  63. OMAP_DSS_VIDEO2 = 2,
  64. OMAP_DSS_VIDEO3 = 3,
  65. OMAP_DSS_WB = 4,
  66. };
  67. enum omap_channel {
  68. OMAP_DSS_CHANNEL_LCD = 0,
  69. OMAP_DSS_CHANNEL_DIGIT = 1,
  70. OMAP_DSS_CHANNEL_LCD2 = 2,
  71. OMAP_DSS_CHANNEL_LCD3 = 3,
  72. OMAP_DSS_CHANNEL_WB = 4,
  73. };
  74. enum omap_color_mode {
  75. OMAP_DSS_COLOR_CLUT1 = 1 << 0, /* BITMAP 1 */
  76. OMAP_DSS_COLOR_CLUT2 = 1 << 1, /* BITMAP 2 */
  77. OMAP_DSS_COLOR_CLUT4 = 1 << 2, /* BITMAP 4 */
  78. OMAP_DSS_COLOR_CLUT8 = 1 << 3, /* BITMAP 8 */
  79. OMAP_DSS_COLOR_RGB12U = 1 << 4, /* RGB12, 16-bit container */
  80. OMAP_DSS_COLOR_ARGB16 = 1 << 5, /* ARGB16 */
  81. OMAP_DSS_COLOR_RGB16 = 1 << 6, /* RGB16 */
  82. OMAP_DSS_COLOR_RGB24U = 1 << 7, /* RGB24, 32-bit container */
  83. OMAP_DSS_COLOR_RGB24P = 1 << 8, /* RGB24, 24-bit container */
  84. OMAP_DSS_COLOR_YUV2 = 1 << 9, /* YUV2 4:2:2 co-sited */
  85. OMAP_DSS_COLOR_UYVY = 1 << 10, /* UYVY 4:2:2 co-sited */
  86. OMAP_DSS_COLOR_ARGB32 = 1 << 11, /* ARGB32 */
  87. OMAP_DSS_COLOR_RGBA32 = 1 << 12, /* RGBA32 */
  88. OMAP_DSS_COLOR_RGBX32 = 1 << 13, /* RGBx32 */
  89. OMAP_DSS_COLOR_NV12 = 1 << 14, /* NV12 format: YUV 4:2:0 */
  90. OMAP_DSS_COLOR_RGBA16 = 1 << 15, /* RGBA16 - 4444 */
  91. OMAP_DSS_COLOR_RGBX16 = 1 << 16, /* RGBx16 - 4444 */
  92. OMAP_DSS_COLOR_ARGB16_1555 = 1 << 17, /* ARGB16 - 1555 */
  93. OMAP_DSS_COLOR_XRGB16_1555 = 1 << 18, /* xRGB16 - 1555 */
  94. };
  95. enum omap_dss_load_mode {
  96. OMAP_DSS_LOAD_CLUT_AND_FRAME = 0,
  97. OMAP_DSS_LOAD_CLUT_ONLY = 1,
  98. OMAP_DSS_LOAD_FRAME_ONLY = 2,
  99. OMAP_DSS_LOAD_CLUT_ONCE_FRAME = 3,
  100. };
  101. enum omap_dss_trans_key_type {
  102. OMAP_DSS_COLOR_KEY_GFX_DST = 0,
  103. OMAP_DSS_COLOR_KEY_VID_SRC = 1,
  104. };
  105. enum omap_dss_signal_level {
  106. OMAPDSS_SIG_ACTIVE_LOW,
  107. OMAPDSS_SIG_ACTIVE_HIGH,
  108. };
  109. enum omap_dss_signal_edge {
  110. OMAPDSS_DRIVE_SIG_FALLING_EDGE,
  111. OMAPDSS_DRIVE_SIG_RISING_EDGE,
  112. };
  113. enum omap_dss_venc_type {
  114. OMAP_DSS_VENC_TYPE_COMPOSITE,
  115. OMAP_DSS_VENC_TYPE_SVIDEO,
  116. };
  117. enum omap_dss_dsi_pixel_format {
  118. OMAP_DSS_DSI_FMT_RGB888,
  119. OMAP_DSS_DSI_FMT_RGB666,
  120. OMAP_DSS_DSI_FMT_RGB666_PACKED,
  121. OMAP_DSS_DSI_FMT_RGB565,
  122. };
  123. enum omap_dss_dsi_mode {
  124. OMAP_DSS_DSI_CMD_MODE = 0,
  125. OMAP_DSS_DSI_VIDEO_MODE,
  126. };
  127. enum omap_display_caps {
  128. OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE = 1 << 0,
  129. OMAP_DSS_DISPLAY_CAP_TEAR_ELIM = 1 << 1,
  130. };
  131. enum omap_dss_display_state {
  132. OMAP_DSS_DISPLAY_DISABLED = 0,
  133. OMAP_DSS_DISPLAY_ACTIVE,
  134. };
  135. enum omap_dss_rotation_type {
  136. OMAP_DSS_ROT_DMA = 1 << 0,
  137. OMAP_DSS_ROT_VRFB = 1 << 1,
  138. OMAP_DSS_ROT_TILER = 1 << 2,
  139. };
  140. /* clockwise rotation angle */
  141. enum omap_dss_rotation_angle {
  142. OMAP_DSS_ROT_0 = 0,
  143. OMAP_DSS_ROT_90 = 1,
  144. OMAP_DSS_ROT_180 = 2,
  145. OMAP_DSS_ROT_270 = 3,
  146. };
  147. enum omap_overlay_caps {
  148. OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
  149. OMAP_DSS_OVL_CAP_GLOBAL_ALPHA = 1 << 1,
  150. OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA = 1 << 2,
  151. OMAP_DSS_OVL_CAP_ZORDER = 1 << 3,
  152. OMAP_DSS_OVL_CAP_POS = 1 << 4,
  153. OMAP_DSS_OVL_CAP_REPLICATION = 1 << 5,
  154. };
  155. enum omap_dss_output_id {
  156. OMAP_DSS_OUTPUT_DPI = 1 << 0,
  157. OMAP_DSS_OUTPUT_DBI = 1 << 1,
  158. OMAP_DSS_OUTPUT_SDI = 1 << 2,
  159. OMAP_DSS_OUTPUT_DSI1 = 1 << 3,
  160. OMAP_DSS_OUTPUT_DSI2 = 1 << 4,
  161. OMAP_DSS_OUTPUT_VENC = 1 << 5,
  162. OMAP_DSS_OUTPUT_HDMI = 1 << 6,
  163. };
  164. /* DSI */
  165. enum omap_dss_dsi_trans_mode {
  166. /* Sync Pulses: both sync start and end packets sent */
  167. OMAP_DSS_DSI_PULSE_MODE,
  168. /* Sync Events: only sync start packets sent */
  169. OMAP_DSS_DSI_EVENT_MODE,
  170. /* Burst: only sync start packets sent, pixels are time compressed */
  171. OMAP_DSS_DSI_BURST_MODE,
  172. };
  173. struct omap_dss_dsi_videomode_timings {
  174. unsigned long hsclk;
  175. unsigned ndl;
  176. unsigned bitspp;
  177. /* pixels */
  178. u16 hact;
  179. /* lines */
  180. u16 vact;
  181. /* DSI video mode blanking data */
  182. /* Unit: byte clock cycles */
  183. u16 hss;
  184. u16 hsa;
  185. u16 hse;
  186. u16 hfp;
  187. u16 hbp;
  188. /* Unit: line clocks */
  189. u16 vsa;
  190. u16 vfp;
  191. u16 vbp;
  192. /* DSI blanking modes */
  193. int blanking_mode;
  194. int hsa_blanking_mode;
  195. int hbp_blanking_mode;
  196. int hfp_blanking_mode;
  197. enum omap_dss_dsi_trans_mode trans_mode;
  198. bool ddr_clk_always_on;
  199. int window_sync;
  200. };
  201. struct omap_dss_dsi_config {
  202. enum omap_dss_dsi_mode mode;
  203. enum omap_dss_dsi_pixel_format pixel_format;
  204. const struct omap_video_timings *timings;
  205. unsigned long hs_clk_min, hs_clk_max;
  206. unsigned long lp_clk_min, lp_clk_max;
  207. bool ddr_clk_always_on;
  208. enum omap_dss_dsi_trans_mode trans_mode;
  209. };
  210. struct omap_video_timings {
  211. /* Unit: pixels */
  212. u16 x_res;
  213. /* Unit: pixels */
  214. u16 y_res;
  215. /* Unit: Hz */
  216. u32 pixelclock;
  217. /* Unit: pixel clocks */
  218. u16 hsw; /* Horizontal synchronization pulse width */
  219. /* Unit: pixel clocks */
  220. u16 hfp; /* Horizontal front porch */
  221. /* Unit: pixel clocks */
  222. u16 hbp; /* Horizontal back porch */
  223. /* Unit: line clocks */
  224. u16 vsw; /* Vertical synchronization pulse width */
  225. /* Unit: line clocks */
  226. u16 vfp; /* Vertical front porch */
  227. /* Unit: line clocks */
  228. u16 vbp; /* Vertical back porch */
  229. /* Vsync logic level */
  230. enum omap_dss_signal_level vsync_level;
  231. /* Hsync logic level */
  232. enum omap_dss_signal_level hsync_level;
  233. /* Interlaced or Progressive timings */
  234. bool interlace;
  235. /* Pixel clock edge to drive LCD data */
  236. enum omap_dss_signal_edge data_pclk_edge;
  237. /* Data enable logic level */
  238. enum omap_dss_signal_level de_level;
  239. /* Pixel clock edges to drive HSYNC and VSYNC signals */
  240. enum omap_dss_signal_edge sync_pclk_edge;
  241. bool double_pixel;
  242. };
  243. /* Hardcoded timings for tv modes. Venc only uses these to
  244. * identify the mode, and does not actually use the configs
  245. * itself. However, the configs should be something that
  246. * a normal monitor can also show */
  247. extern const struct omap_video_timings omap_dss_pal_timings;
  248. extern const struct omap_video_timings omap_dss_ntsc_timings;
  249. struct omap_dss_cpr_coefs {
  250. s16 rr, rg, rb;
  251. s16 gr, gg, gb;
  252. s16 br, bg, bb;
  253. };
  254. struct omap_overlay_info {
  255. dma_addr_t paddr;
  256. dma_addr_t p_uv_addr; /* for NV12 format */
  257. u16 screen_width;
  258. u16 width;
  259. u16 height;
  260. enum omap_color_mode color_mode;
  261. u8 rotation;
  262. enum omap_dss_rotation_type rotation_type;
  263. bool mirror;
  264. u16 pos_x;
  265. u16 pos_y;
  266. u16 out_width; /* if 0, out_width == width */
  267. u16 out_height; /* if 0, out_height == height */
  268. u8 global_alpha;
  269. u8 pre_mult_alpha;
  270. u8 zorder;
  271. };
  272. struct omap_overlay {
  273. struct kobject kobj;
  274. struct list_head list;
  275. /* static fields */
  276. const char *name;
  277. enum omap_plane id;
  278. enum omap_color_mode supported_modes;
  279. enum omap_overlay_caps caps;
  280. /* dynamic fields */
  281. struct omap_overlay_manager *manager;
  282. /*
  283. * The following functions do not block:
  284. *
  285. * is_enabled
  286. * set_overlay_info
  287. * get_overlay_info
  288. *
  289. * The rest of the functions may block and cannot be called from
  290. * interrupt context
  291. */
  292. int (*enable)(struct omap_overlay *ovl);
  293. int (*disable)(struct omap_overlay *ovl);
  294. bool (*is_enabled)(struct omap_overlay *ovl);
  295. int (*set_manager)(struct omap_overlay *ovl,
  296. struct omap_overlay_manager *mgr);
  297. int (*unset_manager)(struct omap_overlay *ovl);
  298. int (*set_overlay_info)(struct omap_overlay *ovl,
  299. struct omap_overlay_info *info);
  300. void (*get_overlay_info)(struct omap_overlay *ovl,
  301. struct omap_overlay_info *info);
  302. int (*wait_for_go)(struct omap_overlay *ovl);
  303. struct omap_dss_device *(*get_device)(struct omap_overlay *ovl);
  304. };
  305. struct omap_overlay_manager_info {
  306. u32 default_color;
  307. enum omap_dss_trans_key_type trans_key_type;
  308. u32 trans_key;
  309. bool trans_enabled;
  310. bool partial_alpha_enabled;
  311. bool cpr_enable;
  312. struct omap_dss_cpr_coefs cpr_coefs;
  313. };
  314. struct omap_overlay_manager {
  315. struct kobject kobj;
  316. /* static fields */
  317. const char *name;
  318. enum omap_channel id;
  319. struct list_head overlays;
  320. enum omap_display_type supported_displays;
  321. enum omap_dss_output_id supported_outputs;
  322. /* dynamic fields */
  323. struct omap_dss_device *output;
  324. /*
  325. * The following functions do not block:
  326. *
  327. * set_manager_info
  328. * get_manager_info
  329. * apply
  330. *
  331. * The rest of the functions may block and cannot be called from
  332. * interrupt context
  333. */
  334. int (*set_output)(struct omap_overlay_manager *mgr,
  335. struct omap_dss_device *output);
  336. int (*unset_output)(struct omap_overlay_manager *mgr);
  337. int (*set_manager_info)(struct omap_overlay_manager *mgr,
  338. struct omap_overlay_manager_info *info);
  339. void (*get_manager_info)(struct omap_overlay_manager *mgr,
  340. struct omap_overlay_manager_info *info);
  341. int (*apply)(struct omap_overlay_manager *mgr);
  342. int (*wait_for_go)(struct omap_overlay_manager *mgr);
  343. int (*wait_for_vsync)(struct omap_overlay_manager *mgr);
  344. struct omap_dss_device *(*get_device)(struct omap_overlay_manager *mgr);
  345. };
  346. /* 22 pins means 1 clk lane and 10 data lanes */
  347. #define OMAP_DSS_MAX_DSI_PINS 22
  348. struct omap_dsi_pin_config {
  349. int num_pins;
  350. /*
  351. * pin numbers in the following order:
  352. * clk+, clk-
  353. * data1+, data1-
  354. * data2+, data2-
  355. * ...
  356. */
  357. int pins[OMAP_DSS_MAX_DSI_PINS];
  358. };
  359. struct omap_dss_writeback_info {
  360. u32 paddr;
  361. u32 p_uv_addr;
  362. u16 buf_width;
  363. u16 width;
  364. u16 height;
  365. enum omap_color_mode color_mode;
  366. u8 rotation;
  367. enum omap_dss_rotation_type rotation_type;
  368. bool mirror;
  369. u8 pre_mult_alpha;
  370. };
  371. struct omapdss_dpi_ops {
  372. int (*connect)(struct omap_dss_device *dssdev,
  373. struct omap_dss_device *dst);
  374. void (*disconnect)(struct omap_dss_device *dssdev,
  375. struct omap_dss_device *dst);
  376. int (*enable)(struct omap_dss_device *dssdev);
  377. void (*disable)(struct omap_dss_device *dssdev);
  378. int (*check_timings)(struct omap_dss_device *dssdev,
  379. struct omap_video_timings *timings);
  380. void (*set_timings)(struct omap_dss_device *dssdev,
  381. struct omap_video_timings *timings);
  382. void (*get_timings)(struct omap_dss_device *dssdev,
  383. struct omap_video_timings *timings);
  384. void (*set_data_lines)(struct omap_dss_device *dssdev, int data_lines);
  385. };
  386. struct omapdss_sdi_ops {
  387. int (*connect)(struct omap_dss_device *dssdev,
  388. struct omap_dss_device *dst);
  389. void (*disconnect)(struct omap_dss_device *dssdev,
  390. struct omap_dss_device *dst);
  391. int (*enable)(struct omap_dss_device *dssdev);
  392. void (*disable)(struct omap_dss_device *dssdev);
  393. int (*check_timings)(struct omap_dss_device *dssdev,
  394. struct omap_video_timings *timings);
  395. void (*set_timings)(struct omap_dss_device *dssdev,
  396. struct omap_video_timings *timings);
  397. void (*get_timings)(struct omap_dss_device *dssdev,
  398. struct omap_video_timings *timings);
  399. void (*set_datapairs)(struct omap_dss_device *dssdev, int datapairs);
  400. };
  401. struct omapdss_dvi_ops {
  402. int (*connect)(struct omap_dss_device *dssdev,
  403. struct omap_dss_device *dst);
  404. void (*disconnect)(struct omap_dss_device *dssdev,
  405. struct omap_dss_device *dst);
  406. int (*enable)(struct omap_dss_device *dssdev);
  407. void (*disable)(struct omap_dss_device *dssdev);
  408. int (*check_timings)(struct omap_dss_device *dssdev,
  409. struct omap_video_timings *timings);
  410. void (*set_timings)(struct omap_dss_device *dssdev,
  411. struct omap_video_timings *timings);
  412. void (*get_timings)(struct omap_dss_device *dssdev,
  413. struct omap_video_timings *timings);
  414. };
  415. struct omapdss_atv_ops {
  416. int (*connect)(struct omap_dss_device *dssdev,
  417. struct omap_dss_device *dst);
  418. void (*disconnect)(struct omap_dss_device *dssdev,
  419. struct omap_dss_device *dst);
  420. int (*enable)(struct omap_dss_device *dssdev);
  421. void (*disable)(struct omap_dss_device *dssdev);
  422. int (*check_timings)(struct omap_dss_device *dssdev,
  423. struct omap_video_timings *timings);
  424. void (*set_timings)(struct omap_dss_device *dssdev,
  425. struct omap_video_timings *timings);
  426. void (*get_timings)(struct omap_dss_device *dssdev,
  427. struct omap_video_timings *timings);
  428. void (*set_type)(struct omap_dss_device *dssdev,
  429. enum omap_dss_venc_type type);
  430. void (*invert_vid_out_polarity)(struct omap_dss_device *dssdev,
  431. bool invert_polarity);
  432. int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
  433. u32 (*get_wss)(struct omap_dss_device *dssdev);
  434. };
  435. struct omapdss_hdmi_ops {
  436. int (*connect)(struct omap_dss_device *dssdev,
  437. struct omap_dss_device *dst);
  438. void (*disconnect)(struct omap_dss_device *dssdev,
  439. struct omap_dss_device *dst);
  440. int (*enable)(struct omap_dss_device *dssdev);
  441. void (*disable)(struct omap_dss_device *dssdev);
  442. int (*check_timings)(struct omap_dss_device *dssdev,
  443. struct omap_video_timings *timings);
  444. void (*set_timings)(struct omap_dss_device *dssdev,
  445. struct omap_video_timings *timings);
  446. void (*get_timings)(struct omap_dss_device *dssdev,
  447. struct omap_video_timings *timings);
  448. int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
  449. bool (*detect)(struct omap_dss_device *dssdev);
  450. int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
  451. int (*set_infoframe)(struct omap_dss_device *dssdev,
  452. const struct hdmi_avi_infoframe *avi);
  453. };
  454. struct omapdss_dsi_ops {
  455. int (*connect)(struct omap_dss_device *dssdev,
  456. struct omap_dss_device *dst);
  457. void (*disconnect)(struct omap_dss_device *dssdev,
  458. struct omap_dss_device *dst);
  459. int (*enable)(struct omap_dss_device *dssdev);
  460. void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
  461. bool enter_ulps);
  462. /* bus configuration */
  463. int (*set_config)(struct omap_dss_device *dssdev,
  464. const struct omap_dss_dsi_config *cfg);
  465. int (*configure_pins)(struct omap_dss_device *dssdev,
  466. const struct omap_dsi_pin_config *pin_cfg);
  467. void (*enable_hs)(struct omap_dss_device *dssdev, int channel,
  468. bool enable);
  469. int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
  470. int (*update)(struct omap_dss_device *dssdev, int channel,
  471. void (*callback)(int, void *), void *data);
  472. void (*bus_lock)(struct omap_dss_device *dssdev);
  473. void (*bus_unlock)(struct omap_dss_device *dssdev);
  474. int (*enable_video_output)(struct omap_dss_device *dssdev, int channel);
  475. void (*disable_video_output)(struct omap_dss_device *dssdev,
  476. int channel);
  477. int (*request_vc)(struct omap_dss_device *dssdev, int *channel);
  478. int (*set_vc_id)(struct omap_dss_device *dssdev, int channel,
  479. int vc_id);
  480. void (*release_vc)(struct omap_dss_device *dssdev, int channel);
  481. /* data transfer */
  482. int (*dcs_write)(struct omap_dss_device *dssdev, int channel,
  483. u8 *data, int len);
  484. int (*dcs_write_nosync)(struct omap_dss_device *dssdev, int channel,
  485. u8 *data, int len);
  486. int (*dcs_read)(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
  487. u8 *data, int len);
  488. int (*gen_write)(struct omap_dss_device *dssdev, int channel,
  489. u8 *data, int len);
  490. int (*gen_write_nosync)(struct omap_dss_device *dssdev, int channel,
  491. u8 *data, int len);
  492. int (*gen_read)(struct omap_dss_device *dssdev, int channel,
  493. u8 *reqdata, int reqlen,
  494. u8 *data, int len);
  495. int (*bta_sync)(struct omap_dss_device *dssdev, int channel);
  496. int (*set_max_rx_packet_size)(struct omap_dss_device *dssdev,
  497. int channel, u16 plen);
  498. };
  499. struct omap_dss_device {
  500. struct kobject kobj;
  501. struct device *dev;
  502. struct module *owner;
  503. struct list_head panel_list;
  504. /* alias in the form of "display%d" */
  505. char alias[16];
  506. enum omap_display_type type;
  507. enum omap_display_type output_type;
  508. union {
  509. struct {
  510. u8 data_lines;
  511. } dpi;
  512. struct {
  513. u8 datapairs;
  514. } sdi;
  515. struct {
  516. int module;
  517. } dsi;
  518. struct {
  519. enum omap_dss_venc_type type;
  520. bool invert_polarity;
  521. } venc;
  522. } phy;
  523. struct {
  524. struct omap_video_timings timings;
  525. enum omap_dss_dsi_pixel_format dsi_pix_fmt;
  526. enum omap_dss_dsi_mode dsi_mode;
  527. } panel;
  528. struct {
  529. u8 pixel_size;
  530. } ctrl;
  531. const char *name;
  532. /* used to match device to driver */
  533. const char *driver_name;
  534. void *data;
  535. struct omap_dss_driver *driver;
  536. union {
  537. const struct omapdss_dpi_ops *dpi;
  538. const struct omapdss_sdi_ops *sdi;
  539. const struct omapdss_dvi_ops *dvi;
  540. const struct omapdss_hdmi_ops *hdmi;
  541. const struct omapdss_atv_ops *atv;
  542. const struct omapdss_dsi_ops *dsi;
  543. } ops;
  544. /* helper variable for driver suspend/resume */
  545. bool activate_after_resume;
  546. enum omap_display_caps caps;
  547. struct omap_dss_device *src;
  548. enum omap_dss_display_state state;
  549. /* OMAP DSS output specific fields */
  550. struct list_head list;
  551. /* DISPC channel for this output */
  552. enum omap_channel dispc_channel;
  553. bool dispc_channel_connected;
  554. /* output instance */
  555. enum omap_dss_output_id id;
  556. /* the port number in the DT node */
  557. int port_num;
  558. /* dynamic fields */
  559. struct omap_overlay_manager *manager;
  560. struct omap_dss_device *dst;
  561. };
  562. struct omap_dss_driver {
  563. int (*probe)(struct omap_dss_device *);
  564. void (*remove)(struct omap_dss_device *);
  565. int (*connect)(struct omap_dss_device *dssdev);
  566. void (*disconnect)(struct omap_dss_device *dssdev);
  567. int (*enable)(struct omap_dss_device *display);
  568. void (*disable)(struct omap_dss_device *display);
  569. int (*run_test)(struct omap_dss_device *display, int test);
  570. int (*update)(struct omap_dss_device *dssdev,
  571. u16 x, u16 y, u16 w, u16 h);
  572. int (*sync)(struct omap_dss_device *dssdev);
  573. int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
  574. int (*get_te)(struct omap_dss_device *dssdev);
  575. u8 (*get_rotate)(struct omap_dss_device *dssdev);
  576. int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
  577. bool (*get_mirror)(struct omap_dss_device *dssdev);
  578. int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
  579. int (*memory_read)(struct omap_dss_device *dssdev,
  580. void *buf, size_t size,
  581. u16 x, u16 y, u16 w, u16 h);
  582. void (*get_resolution)(struct omap_dss_device *dssdev,
  583. u16 *xres, u16 *yres);
  584. void (*get_dimensions)(struct omap_dss_device *dssdev,
  585. u32 *width, u32 *height);
  586. int (*get_recommended_bpp)(struct omap_dss_device *dssdev);
  587. int (*check_timings)(struct omap_dss_device *dssdev,
  588. struct omap_video_timings *timings);
  589. void (*set_timings)(struct omap_dss_device *dssdev,
  590. struct omap_video_timings *timings);
  591. void (*get_timings)(struct omap_dss_device *dssdev,
  592. struct omap_video_timings *timings);
  593. int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
  594. u32 (*get_wss)(struct omap_dss_device *dssdev);
  595. int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
  596. bool (*detect)(struct omap_dss_device *dssdev);
  597. int (*set_hdmi_mode)(struct omap_dss_device *dssdev, bool hdmi_mode);
  598. int (*set_hdmi_infoframe)(struct omap_dss_device *dssdev,
  599. const struct hdmi_avi_infoframe *avi);
  600. };
  601. #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
  602. typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
  603. #if IS_ENABLED(CONFIG_FB_OMAP2)
  604. enum omapdss_version omapdss_get_version(void);
  605. bool omapdss_is_initialized(void);
  606. int omap_dss_register_driver(struct omap_dss_driver *);
  607. void omap_dss_unregister_driver(struct omap_dss_driver *);
  608. int omapdss_register_display(struct omap_dss_device *dssdev);
  609. void omapdss_unregister_display(struct omap_dss_device *dssdev);
  610. struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
  611. void omap_dss_put_device(struct omap_dss_device *dssdev);
  612. struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
  613. struct omap_dss_device *omap_dss_find_device(void *data,
  614. int (*match)(struct omap_dss_device *dssdev, void *data));
  615. const char *omapdss_get_default_display_name(void);
  616. void videomode_to_omap_video_timings(const struct videomode *vm,
  617. struct omap_video_timings *ovt);
  618. void omap_video_timings_to_videomode(const struct omap_video_timings *ovt,
  619. struct videomode *vm);
  620. int dss_feat_get_num_mgrs(void);
  621. int dss_feat_get_num_ovls(void);
  622. enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane);
  623. int omap_dss_get_num_overlay_managers(void);
  624. struct omap_overlay_manager *omap_dss_get_overlay_manager(int num);
  625. int omap_dss_get_num_overlays(void);
  626. struct omap_overlay *omap_dss_get_overlay(int num);
  627. int omapdss_register_output(struct omap_dss_device *output);
  628. void omapdss_unregister_output(struct omap_dss_device *output);
  629. struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
  630. struct omap_dss_device *omap_dss_find_output(const char *name);
  631. struct omap_dss_device *omap_dss_find_output_by_port_node(struct device_node *port);
  632. int omapdss_output_set_device(struct omap_dss_device *out,
  633. struct omap_dss_device *dssdev);
  634. int omapdss_output_unset_device(struct omap_dss_device *out);
  635. struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev);
  636. struct omap_overlay_manager *omapdss_find_mgr_from_display(struct omap_dss_device *dssdev);
  637. void omapdss_default_get_resolution(struct omap_dss_device *dssdev,
  638. u16 *xres, u16 *yres);
  639. int omapdss_default_get_recommended_bpp(struct omap_dss_device *dssdev);
  640. void omapdss_default_get_timings(struct omap_dss_device *dssdev,
  641. struct omap_video_timings *timings);
  642. int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
  643. int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
  644. int omapdss_compat_init(void);
  645. void omapdss_compat_uninit(void);
  646. static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
  647. {
  648. return dssdev->src;
  649. }
  650. static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
  651. {
  652. return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
  653. }
  654. struct device_node *
  655. omapdss_of_get_next_port(const struct device_node *parent,
  656. struct device_node *prev);
  657. struct device_node *
  658. omapdss_of_get_next_endpoint(const struct device_node *parent,
  659. struct device_node *prev);
  660. struct device_node *
  661. omapdss_of_get_first_endpoint(const struct device_node *parent);
  662. struct omap_dss_device *
  663. omapdss_of_find_source_for_first_ep(struct device_node *node);
  664. #else
  665. static inline enum omapdss_version omapdss_get_version(void)
  666. { return OMAPDSS_VER_UNKNOWN; };
  667. static inline bool omapdss_is_initialized(void)
  668. { return false; };
  669. static inline int omap_dispc_register_isr(omap_dispc_isr_t isr,
  670. void *arg, u32 mask)
  671. { return 0; };
  672. static inline int omap_dispc_unregister_isr(omap_dispc_isr_t isr,
  673. void *arg, u32 mask)
  674. { return 0; };
  675. static inline struct omap_dss_device
  676. *omap_dss_get_device(struct omap_dss_device *dssdev)
  677. { return NULL; };
  678. static inline struct omap_dss_device
  679. *omap_dss_get_next_device(struct omap_dss_device *from)
  680. {return NULL; };
  681. static inline void omap_dss_put_device(struct omap_dss_device *dssdev) {};
  682. static inline int omapdss_compat_init(void)
  683. { return 0; };
  684. static inline void omapdss_compat_uninit(void) {};
  685. static inline int omap_dss_get_num_overlay_managers(void)
  686. { return 0; };
  687. static inline struct omap_overlay_manager *omap_dss_get_overlay_manager(int num)
  688. { return NULL; };
  689. static inline int omap_dss_get_num_overlays(void)
  690. { return 0; };
  691. static inline struct omap_overlay *omap_dss_get_overlay(int num)
  692. { return NULL; };
  693. #endif /* FB_OMAP2 */
  694. #endif /* __OMAPFB_DSS_H */