omapdss.h 28 KB

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