omapdss.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. /*
  2. * Copyright (C) 2008 Nokia Corporation
  3. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.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_OMAPDSS_H
  18. #define __OMAP_OMAPDSS_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. #define DISPC_IRQ_FRAMEDONE (1 << 0)
  25. #define DISPC_IRQ_VSYNC (1 << 1)
  26. #define DISPC_IRQ_EVSYNC_EVEN (1 << 2)
  27. #define DISPC_IRQ_EVSYNC_ODD (1 << 3)
  28. #define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4)
  29. #define DISPC_IRQ_PROG_LINE_NUM (1 << 5)
  30. #define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6)
  31. #define DISPC_IRQ_GFX_END_WIN (1 << 7)
  32. #define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8)
  33. #define DISPC_IRQ_OCP_ERR (1 << 9)
  34. #define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10)
  35. #define DISPC_IRQ_VID1_END_WIN (1 << 11)
  36. #define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12)
  37. #define DISPC_IRQ_VID2_END_WIN (1 << 13)
  38. #define DISPC_IRQ_SYNC_LOST (1 << 14)
  39. #define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15)
  40. #define DISPC_IRQ_WAKEUP (1 << 16)
  41. #define DISPC_IRQ_SYNC_LOST2 (1 << 17)
  42. #define DISPC_IRQ_VSYNC2 (1 << 18)
  43. #define DISPC_IRQ_VID3_END_WIN (1 << 19)
  44. #define DISPC_IRQ_VID3_FIFO_UNDERFLOW (1 << 20)
  45. #define DISPC_IRQ_ACBIAS_COUNT_STAT2 (1 << 21)
  46. #define DISPC_IRQ_FRAMEDONE2 (1 << 22)
  47. #define DISPC_IRQ_FRAMEDONEWB (1 << 23)
  48. #define DISPC_IRQ_FRAMEDONETV (1 << 24)
  49. #define DISPC_IRQ_WBBUFFEROVERFLOW (1 << 25)
  50. #define DISPC_IRQ_SYNC_LOST3 (1 << 27)
  51. #define DISPC_IRQ_VSYNC3 (1 << 28)
  52. #define DISPC_IRQ_ACBIAS_COUNT_STAT3 (1 << 29)
  53. #define DISPC_IRQ_FRAMEDONE3 (1 << 30)
  54. struct omap_dss_device;
  55. struct omap_overlay_manager;
  56. struct dss_lcd_mgr_config;
  57. struct snd_aes_iec958;
  58. struct snd_cea_861_aud_if;
  59. enum omap_display_type {
  60. OMAP_DISPLAY_TYPE_NONE = 0,
  61. OMAP_DISPLAY_TYPE_DPI = 1 << 0,
  62. OMAP_DISPLAY_TYPE_DBI = 1 << 1,
  63. OMAP_DISPLAY_TYPE_SDI = 1 << 2,
  64. OMAP_DISPLAY_TYPE_DSI = 1 << 3,
  65. OMAP_DISPLAY_TYPE_VENC = 1 << 4,
  66. OMAP_DISPLAY_TYPE_HDMI = 1 << 5,
  67. };
  68. enum omap_plane {
  69. OMAP_DSS_GFX = 0,
  70. OMAP_DSS_VIDEO1 = 1,
  71. OMAP_DSS_VIDEO2 = 2,
  72. OMAP_DSS_VIDEO3 = 3,
  73. OMAP_DSS_WB = 4,
  74. };
  75. enum omap_channel {
  76. OMAP_DSS_CHANNEL_LCD = 0,
  77. OMAP_DSS_CHANNEL_DIGIT = 1,
  78. OMAP_DSS_CHANNEL_LCD2 = 2,
  79. OMAP_DSS_CHANNEL_LCD3 = 3,
  80. };
  81. enum omap_color_mode {
  82. OMAP_DSS_COLOR_CLUT1 = 1 << 0, /* BITMAP 1 */
  83. OMAP_DSS_COLOR_CLUT2 = 1 << 1, /* BITMAP 2 */
  84. OMAP_DSS_COLOR_CLUT4 = 1 << 2, /* BITMAP 4 */
  85. OMAP_DSS_COLOR_CLUT8 = 1 << 3, /* BITMAP 8 */
  86. OMAP_DSS_COLOR_RGB12U = 1 << 4, /* RGB12, 16-bit container */
  87. OMAP_DSS_COLOR_ARGB16 = 1 << 5, /* ARGB16 */
  88. OMAP_DSS_COLOR_RGB16 = 1 << 6, /* RGB16 */
  89. OMAP_DSS_COLOR_RGB24U = 1 << 7, /* RGB24, 32-bit container */
  90. OMAP_DSS_COLOR_RGB24P = 1 << 8, /* RGB24, 24-bit container */
  91. OMAP_DSS_COLOR_YUV2 = 1 << 9, /* YUV2 4:2:2 co-sited */
  92. OMAP_DSS_COLOR_UYVY = 1 << 10, /* UYVY 4:2:2 co-sited */
  93. OMAP_DSS_COLOR_ARGB32 = 1 << 11, /* ARGB32 */
  94. OMAP_DSS_COLOR_RGBA32 = 1 << 12, /* RGBA32 */
  95. OMAP_DSS_COLOR_RGBX32 = 1 << 13, /* RGBx32 */
  96. OMAP_DSS_COLOR_NV12 = 1 << 14, /* NV12 format: YUV 4:2:0 */
  97. OMAP_DSS_COLOR_RGBA16 = 1 << 15, /* RGBA16 - 4444 */
  98. OMAP_DSS_COLOR_RGBX16 = 1 << 16, /* RGBx16 - 4444 */
  99. OMAP_DSS_COLOR_ARGB16_1555 = 1 << 17, /* ARGB16 - 1555 */
  100. OMAP_DSS_COLOR_XRGB16_1555 = 1 << 18, /* xRGB16 - 1555 */
  101. };
  102. enum omap_dss_load_mode {
  103. OMAP_DSS_LOAD_CLUT_AND_FRAME = 0,
  104. OMAP_DSS_LOAD_CLUT_ONLY = 1,
  105. OMAP_DSS_LOAD_FRAME_ONLY = 2,
  106. OMAP_DSS_LOAD_CLUT_ONCE_FRAME = 3,
  107. };
  108. enum omap_dss_trans_key_type {
  109. OMAP_DSS_COLOR_KEY_GFX_DST = 0,
  110. OMAP_DSS_COLOR_KEY_VID_SRC = 1,
  111. };
  112. enum omap_rfbi_te_mode {
  113. OMAP_DSS_RFBI_TE_MODE_1 = 1,
  114. OMAP_DSS_RFBI_TE_MODE_2 = 2,
  115. };
  116. enum omap_dss_signal_level {
  117. OMAPDSS_SIG_ACTIVE_HIGH = 0,
  118. OMAPDSS_SIG_ACTIVE_LOW = 1,
  119. };
  120. enum omap_dss_signal_edge {
  121. OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
  122. OMAPDSS_DRIVE_SIG_RISING_EDGE,
  123. OMAPDSS_DRIVE_SIG_FALLING_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_audio_state {
  148. OMAP_DSS_AUDIO_DISABLED = 0,
  149. OMAP_DSS_AUDIO_ENABLED,
  150. OMAP_DSS_AUDIO_CONFIGURED,
  151. OMAP_DSS_AUDIO_PLAYING,
  152. };
  153. enum omap_dss_rotation_type {
  154. OMAP_DSS_ROT_DMA = 1 << 0,
  155. OMAP_DSS_ROT_VRFB = 1 << 1,
  156. OMAP_DSS_ROT_TILER = 1 << 2,
  157. };
  158. /* clockwise rotation angle */
  159. enum omap_dss_rotation_angle {
  160. OMAP_DSS_ROT_0 = 0,
  161. OMAP_DSS_ROT_90 = 1,
  162. OMAP_DSS_ROT_180 = 2,
  163. OMAP_DSS_ROT_270 = 3,
  164. };
  165. enum omap_overlay_caps {
  166. OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
  167. OMAP_DSS_OVL_CAP_GLOBAL_ALPHA = 1 << 1,
  168. OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA = 1 << 2,
  169. OMAP_DSS_OVL_CAP_ZORDER = 1 << 3,
  170. OMAP_DSS_OVL_CAP_POS = 1 << 4,
  171. OMAP_DSS_OVL_CAP_REPLICATION = 1 << 5,
  172. };
  173. enum omap_overlay_manager_caps {
  174. OMAP_DSS_DUMMY_VALUE, /* add a dummy value to prevent compiler error */
  175. };
  176. enum omap_dss_clk_source {
  177. OMAP_DSS_CLK_SRC_FCK = 0, /* OMAP2/3: DSS1_ALWON_FCLK
  178. * OMAP4: DSS_FCLK */
  179. OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC, /* OMAP3: DSI1_PLL_FCLK
  180. * OMAP4: PLL1_CLK1 */
  181. OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI, /* OMAP3: DSI2_PLL_FCLK
  182. * OMAP4: PLL1_CLK2 */
  183. OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC, /* OMAP4: PLL2_CLK1 */
  184. OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI, /* OMAP4: PLL2_CLK2 */
  185. };
  186. enum omap_hdmi_flags {
  187. OMAP_HDMI_SDA_SCL_EXTERNAL_PULLUP = 1 << 0,
  188. };
  189. enum omap_dss_output_id {
  190. OMAP_DSS_OUTPUT_DPI = 1 << 0,
  191. OMAP_DSS_OUTPUT_DBI = 1 << 1,
  192. OMAP_DSS_OUTPUT_SDI = 1 << 2,
  193. OMAP_DSS_OUTPUT_DSI1 = 1 << 3,
  194. OMAP_DSS_OUTPUT_DSI2 = 1 << 4,
  195. OMAP_DSS_OUTPUT_VENC = 1 << 5,
  196. OMAP_DSS_OUTPUT_HDMI = 1 << 6,
  197. };
  198. /* RFBI */
  199. struct rfbi_timings {
  200. int cs_on_time;
  201. int cs_off_time;
  202. int we_on_time;
  203. int we_off_time;
  204. int re_on_time;
  205. int re_off_time;
  206. int we_cycle_time;
  207. int re_cycle_time;
  208. int cs_pulse_width;
  209. int access_time;
  210. int clk_div;
  211. u32 tim[5]; /* set by rfbi_convert_timings() */
  212. int converted;
  213. };
  214. void omap_rfbi_write_command(const void *buf, u32 len);
  215. void omap_rfbi_read_data(void *buf, u32 len);
  216. void omap_rfbi_write_data(const void *buf, u32 len);
  217. void omap_rfbi_write_pixels(const void __iomem *buf, int scr_width,
  218. u16 x, u16 y,
  219. u16 w, u16 h);
  220. int omap_rfbi_enable_te(bool enable, unsigned line);
  221. int omap_rfbi_setup_te(enum omap_rfbi_te_mode mode,
  222. unsigned hs_pulse_time, unsigned vs_pulse_time,
  223. int hs_pol_inv, int vs_pol_inv, int extif_div);
  224. void rfbi_bus_lock(void);
  225. void rfbi_bus_unlock(void);
  226. /* DSI */
  227. enum omap_dss_dsi_trans_mode {
  228. /* Sync Pulses: both sync start and end packets sent */
  229. OMAP_DSS_DSI_PULSE_MODE,
  230. /* Sync Events: only sync start packets sent */
  231. OMAP_DSS_DSI_EVENT_MODE,
  232. /* Burst: only sync start packets sent, pixels are time compressed */
  233. OMAP_DSS_DSI_BURST_MODE,
  234. };
  235. struct omap_dss_dsi_videomode_timings {
  236. unsigned long hsclk;
  237. unsigned ndl;
  238. unsigned bitspp;
  239. /* pixels */
  240. u16 hact;
  241. /* lines */
  242. u16 vact;
  243. /* DSI video mode blanking data */
  244. /* Unit: byte clock cycles */
  245. u16 hss;
  246. u16 hsa;
  247. u16 hse;
  248. u16 hfp;
  249. u16 hbp;
  250. /* Unit: line clocks */
  251. u16 vsa;
  252. u16 vfp;
  253. u16 vbp;
  254. /* DSI blanking modes */
  255. int blanking_mode;
  256. int hsa_blanking_mode;
  257. int hbp_blanking_mode;
  258. int hfp_blanking_mode;
  259. enum omap_dss_dsi_trans_mode trans_mode;
  260. bool ddr_clk_always_on;
  261. int window_sync;
  262. };
  263. struct omap_dss_dsi_config {
  264. enum omap_dss_dsi_mode mode;
  265. enum omap_dss_dsi_pixel_format pixel_format;
  266. const struct omap_video_timings *timings;
  267. unsigned long hs_clk_min, hs_clk_max;
  268. unsigned long lp_clk_min, lp_clk_max;
  269. bool ddr_clk_always_on;
  270. enum omap_dss_dsi_trans_mode trans_mode;
  271. };
  272. void dsi_bus_lock(struct omap_dss_device *dssdev);
  273. void dsi_bus_unlock(struct omap_dss_device *dssdev);
  274. int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel, u8 *data,
  275. int len);
  276. int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, u8 *data,
  277. int len);
  278. int dsi_vc_dcs_write_0(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd);
  279. int dsi_vc_generic_write_0(struct omap_dss_device *dssdev, int channel);
  280. int dsi_vc_dcs_write_1(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
  281. u8 param);
  282. int dsi_vc_generic_write_1(struct omap_dss_device *dssdev, int channel,
  283. u8 param);
  284. int dsi_vc_generic_write_2(struct omap_dss_device *dssdev, int channel,
  285. u8 param1, u8 param2);
  286. int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel,
  287. u8 *data, int len);
  288. int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int channel,
  289. u8 *data, int len);
  290. int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd,
  291. u8 *buf, int buflen);
  292. int dsi_vc_generic_read_0(struct omap_dss_device *dssdev, int channel, u8 *buf,
  293. int buflen);
  294. int dsi_vc_generic_read_1(struct omap_dss_device *dssdev, int channel, u8 param,
  295. u8 *buf, int buflen);
  296. int dsi_vc_generic_read_2(struct omap_dss_device *dssdev, int channel,
  297. u8 param1, u8 param2, u8 *buf, int buflen);
  298. int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel,
  299. u16 len);
  300. int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel);
  301. int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel);
  302. int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel);
  303. void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel);
  304. enum omapdss_version {
  305. OMAPDSS_VER_UNKNOWN = 0,
  306. OMAPDSS_VER_OMAP24xx,
  307. OMAPDSS_VER_OMAP34xx_ES1, /* OMAP3430 ES1.0, 2.0 */
  308. OMAPDSS_VER_OMAP34xx_ES3, /* OMAP3430 ES3.0+ */
  309. OMAPDSS_VER_OMAP3630,
  310. OMAPDSS_VER_AM35xx,
  311. OMAPDSS_VER_OMAP4430_ES1, /* OMAP4430 ES1.0 */
  312. OMAPDSS_VER_OMAP4430_ES2, /* OMAP4430 ES2.0, 2.1, 2.2 */
  313. OMAPDSS_VER_OMAP4, /* All other OMAP4s */
  314. OMAPDSS_VER_OMAP5,
  315. };
  316. /* Board specific data */
  317. struct omap_dss_board_info {
  318. int (*get_context_loss_count)(struct device *dev);
  319. int num_devices;
  320. struct omap_dss_device **devices;
  321. struct omap_dss_device *default_device;
  322. const char *default_display_name;
  323. int (*dsi_enable_pads)(int dsi_id, unsigned lane_mask);
  324. void (*dsi_disable_pads)(int dsi_id, unsigned lane_mask);
  325. int (*set_min_bus_tput)(struct device *dev, unsigned long r);
  326. enum omapdss_version version;
  327. };
  328. /* Init with the board info */
  329. extern int omap_display_init(struct omap_dss_board_info *board_data);
  330. /* HDMI mux init*/
  331. extern int omap_hdmi_init(enum omap_hdmi_flags flags);
  332. struct omap_video_timings {
  333. /* Unit: pixels */
  334. u16 x_res;
  335. /* Unit: pixels */
  336. u16 y_res;
  337. /* Unit: KHz */
  338. u32 pixel_clock;
  339. /* Unit: pixel clocks */
  340. u16 hsw; /* Horizontal synchronization pulse width */
  341. /* Unit: pixel clocks */
  342. u16 hfp; /* Horizontal front porch */
  343. /* Unit: pixel clocks */
  344. u16 hbp; /* Horizontal back porch */
  345. /* Unit: line clocks */
  346. u16 vsw; /* Vertical synchronization pulse width */
  347. /* Unit: line clocks */
  348. u16 vfp; /* Vertical front porch */
  349. /* Unit: line clocks */
  350. u16 vbp; /* Vertical back porch */
  351. /* Vsync logic level */
  352. enum omap_dss_signal_level vsync_level;
  353. /* Hsync logic level */
  354. enum omap_dss_signal_level hsync_level;
  355. /* Interlaced or Progressive timings */
  356. bool interlace;
  357. /* Pixel clock edge to drive LCD data */
  358. enum omap_dss_signal_edge data_pclk_edge;
  359. /* Data enable logic level */
  360. enum omap_dss_signal_level de_level;
  361. /* Pixel clock edges to drive HSYNC and VSYNC signals */
  362. enum omap_dss_signal_edge sync_pclk_edge;
  363. };
  364. #ifdef CONFIG_OMAP2_DSS_VENC
  365. /* Hardcoded timings for tv modes. Venc only uses these to
  366. * identify the mode, and does not actually use the configs
  367. * itself. However, the configs should be something that
  368. * a normal monitor can also show */
  369. extern const struct omap_video_timings omap_dss_pal_timings;
  370. extern const struct omap_video_timings omap_dss_ntsc_timings;
  371. #endif
  372. struct omap_dss_cpr_coefs {
  373. s16 rr, rg, rb;
  374. s16 gr, gg, gb;
  375. s16 br, bg, bb;
  376. };
  377. struct omap_overlay_info {
  378. u32 paddr;
  379. u32 p_uv_addr; /* for NV12 format */
  380. u16 screen_width;
  381. u16 width;
  382. u16 height;
  383. enum omap_color_mode color_mode;
  384. u8 rotation;
  385. enum omap_dss_rotation_type rotation_type;
  386. bool mirror;
  387. u16 pos_x;
  388. u16 pos_y;
  389. u16 out_width; /* if 0, out_width == width */
  390. u16 out_height; /* if 0, out_height == height */
  391. u8 global_alpha;
  392. u8 pre_mult_alpha;
  393. u8 zorder;
  394. };
  395. struct omap_overlay {
  396. struct kobject kobj;
  397. struct list_head list;
  398. /* static fields */
  399. const char *name;
  400. enum omap_plane id;
  401. enum omap_color_mode supported_modes;
  402. enum omap_overlay_caps caps;
  403. /* dynamic fields */
  404. struct omap_overlay_manager *manager;
  405. /*
  406. * The following functions do not block:
  407. *
  408. * is_enabled
  409. * set_overlay_info
  410. * get_overlay_info
  411. *
  412. * The rest of the functions may block and cannot be called from
  413. * interrupt context
  414. */
  415. int (*enable)(struct omap_overlay *ovl);
  416. int (*disable)(struct omap_overlay *ovl);
  417. bool (*is_enabled)(struct omap_overlay *ovl);
  418. int (*set_manager)(struct omap_overlay *ovl,
  419. struct omap_overlay_manager *mgr);
  420. int (*unset_manager)(struct omap_overlay *ovl);
  421. int (*set_overlay_info)(struct omap_overlay *ovl,
  422. struct omap_overlay_info *info);
  423. void (*get_overlay_info)(struct omap_overlay *ovl,
  424. struct omap_overlay_info *info);
  425. int (*wait_for_go)(struct omap_overlay *ovl);
  426. struct omap_dss_device *(*get_device)(struct omap_overlay *ovl);
  427. };
  428. struct omap_overlay_manager_info {
  429. u32 default_color;
  430. enum omap_dss_trans_key_type trans_key_type;
  431. u32 trans_key;
  432. bool trans_enabled;
  433. bool partial_alpha_enabled;
  434. bool cpr_enable;
  435. struct omap_dss_cpr_coefs cpr_coefs;
  436. };
  437. struct omap_overlay_manager {
  438. struct kobject kobj;
  439. /* static fields */
  440. const char *name;
  441. enum omap_channel id;
  442. enum omap_overlay_manager_caps caps;
  443. struct list_head overlays;
  444. enum omap_display_type supported_displays;
  445. enum omap_dss_output_id supported_outputs;
  446. /* dynamic fields */
  447. struct omap_dss_device *output;
  448. /*
  449. * The following functions do not block:
  450. *
  451. * set_manager_info
  452. * get_manager_info
  453. * apply
  454. *
  455. * The rest of the functions may block and cannot be called from
  456. * interrupt context
  457. */
  458. int (*set_output)(struct omap_overlay_manager *mgr,
  459. struct omap_dss_device *output);
  460. int (*unset_output)(struct omap_overlay_manager *mgr);
  461. int (*set_manager_info)(struct omap_overlay_manager *mgr,
  462. struct omap_overlay_manager_info *info);
  463. void (*get_manager_info)(struct omap_overlay_manager *mgr,
  464. struct omap_overlay_manager_info *info);
  465. int (*apply)(struct omap_overlay_manager *mgr);
  466. int (*wait_for_go)(struct omap_overlay_manager *mgr);
  467. int (*wait_for_vsync)(struct omap_overlay_manager *mgr);
  468. struct omap_dss_device *(*get_device)(struct omap_overlay_manager *mgr);
  469. };
  470. /* 22 pins means 1 clk lane and 10 data lanes */
  471. #define OMAP_DSS_MAX_DSI_PINS 22
  472. struct omap_dsi_pin_config {
  473. int num_pins;
  474. /*
  475. * pin numbers in the following order:
  476. * clk+, clk-
  477. * data1+, data1-
  478. * data2+, data2-
  479. * ...
  480. */
  481. int pins[OMAP_DSS_MAX_DSI_PINS];
  482. };
  483. struct omap_dss_writeback_info {
  484. u32 paddr;
  485. u32 p_uv_addr;
  486. u16 buf_width;
  487. u16 width;
  488. u16 height;
  489. enum omap_color_mode color_mode;
  490. u8 rotation;
  491. enum omap_dss_rotation_type rotation_type;
  492. bool mirror;
  493. u8 pre_mult_alpha;
  494. };
  495. struct omap_dss_device {
  496. /* old device, to be removed */
  497. struct device old_dev;
  498. /* new device, pointer to panel device */
  499. struct device *dev;
  500. struct module *owner;
  501. struct list_head panel_list;
  502. /* alias in the form of "display%d" */
  503. char alias[16];
  504. enum omap_display_type type;
  505. enum omap_display_type output_type;
  506. /* obsolete, to be removed */
  507. enum omap_channel channel;
  508. union {
  509. struct {
  510. u8 data_lines;
  511. } dpi;
  512. struct {
  513. u8 channel;
  514. u8 data_lines;
  515. } rfbi;
  516. struct {
  517. u8 datapairs;
  518. } sdi;
  519. struct {
  520. int module;
  521. } dsi;
  522. struct {
  523. enum omap_dss_venc_type type;
  524. bool invert_polarity;
  525. } venc;
  526. } phy;
  527. struct {
  528. struct omap_video_timings timings;
  529. enum omap_dss_dsi_pixel_format dsi_pix_fmt;
  530. enum omap_dss_dsi_mode dsi_mode;
  531. } panel;
  532. struct {
  533. u8 pixel_size;
  534. struct rfbi_timings rfbi_timings;
  535. } ctrl;
  536. const char *name;
  537. /* used to match device to driver */
  538. const char *driver_name;
  539. void *data;
  540. struct omap_dss_driver *driver;
  541. /* helper variable for driver suspend/resume */
  542. bool activate_after_resume;
  543. enum omap_display_caps caps;
  544. struct omap_dss_device *output;
  545. enum omap_dss_display_state state;
  546. enum omap_dss_audio_state audio_state;
  547. /* OMAP DSS output specific fields */
  548. struct list_head list;
  549. /* DISPC channel for this output */
  550. enum omap_channel dispc_channel;
  551. /* output instance */
  552. enum omap_dss_output_id id;
  553. /* dynamic fields */
  554. struct omap_overlay_manager *manager;
  555. struct omap_dss_device *device;
  556. };
  557. struct omap_dss_hdmi_data
  558. {
  559. int ct_cp_hpd_gpio;
  560. int ls_oe_gpio;
  561. int hpd_gpio;
  562. };
  563. struct omap_dss_audio {
  564. struct snd_aes_iec958 *iec;
  565. struct snd_cea_861_aud_if *cea;
  566. };
  567. struct omap_dss_driver {
  568. struct device_driver driver;
  569. int (*probe)(struct omap_dss_device *);
  570. void (*remove)(struct omap_dss_device *);
  571. int (*connect)(struct omap_dss_device *dssdev);
  572. void (*disconnect)(struct omap_dss_device *dssdev);
  573. int (*enable)(struct omap_dss_device *display);
  574. void (*disable)(struct omap_dss_device *display);
  575. int (*run_test)(struct omap_dss_device *display, int test);
  576. int (*update)(struct omap_dss_device *dssdev,
  577. u16 x, u16 y, u16 w, u16 h);
  578. int (*sync)(struct omap_dss_device *dssdev);
  579. int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
  580. int (*get_te)(struct omap_dss_device *dssdev);
  581. u8 (*get_rotate)(struct omap_dss_device *dssdev);
  582. int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
  583. bool (*get_mirror)(struct omap_dss_device *dssdev);
  584. int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
  585. int (*memory_read)(struct omap_dss_device *dssdev,
  586. void *buf, size_t size,
  587. u16 x, u16 y, u16 w, u16 h);
  588. void (*get_resolution)(struct omap_dss_device *dssdev,
  589. u16 *xres, u16 *yres);
  590. void (*get_dimensions)(struct omap_dss_device *dssdev,
  591. u32 *width, u32 *height);
  592. int (*get_recommended_bpp)(struct omap_dss_device *dssdev);
  593. int (*check_timings)(struct omap_dss_device *dssdev,
  594. struct omap_video_timings *timings);
  595. void (*set_timings)(struct omap_dss_device *dssdev,
  596. struct omap_video_timings *timings);
  597. void (*get_timings)(struct omap_dss_device *dssdev,
  598. struct omap_video_timings *timings);
  599. int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
  600. u32 (*get_wss)(struct omap_dss_device *dssdev);
  601. int (*read_edid)(struct omap_dss_device *dssdev, u8 *buf, int len);
  602. bool (*detect)(struct omap_dss_device *dssdev);
  603. /*
  604. * For display drivers that support audio. This encompasses
  605. * HDMI and DisplayPort at the moment.
  606. */
  607. /*
  608. * Note: These functions might sleep. Do not call while
  609. * holding a spinlock/readlock.
  610. */
  611. int (*audio_enable)(struct omap_dss_device *dssdev);
  612. void (*audio_disable)(struct omap_dss_device *dssdev);
  613. bool (*audio_supported)(struct omap_dss_device *dssdev);
  614. int (*audio_config)(struct omap_dss_device *dssdev,
  615. struct omap_dss_audio *audio);
  616. /* Note: These functions may not sleep */
  617. int (*audio_start)(struct omap_dss_device *dssdev);
  618. void (*audio_stop)(struct omap_dss_device *dssdev);
  619. };
  620. enum omapdss_version omapdss_get_version(void);
  621. bool omapdss_is_initialized(void);
  622. int omap_dss_register_driver(struct omap_dss_driver *);
  623. void omap_dss_unregister_driver(struct omap_dss_driver *);
  624. int omapdss_register_display(struct omap_dss_device *dssdev);
  625. void omapdss_unregister_display(struct omap_dss_device *dssdev);
  626. struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
  627. void omap_dss_put_device(struct omap_dss_device *dssdev);
  628. #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
  629. struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
  630. struct omap_dss_device *omap_dss_find_device(void *data,
  631. int (*match)(struct omap_dss_device *dssdev, void *data));
  632. const char *omapdss_get_default_display_name(void);
  633. void videomode_to_omap_video_timings(const struct videomode *vm,
  634. struct omap_video_timings *ovt);
  635. void omap_video_timings_to_videomode(const struct omap_video_timings *ovt,
  636. struct videomode *vm);
  637. int dss_feat_get_num_mgrs(void);
  638. int dss_feat_get_num_ovls(void);
  639. enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel);
  640. enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel);
  641. enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane plane);
  642. int omap_dss_get_num_overlay_managers(void);
  643. struct omap_overlay_manager *omap_dss_get_overlay_manager(int num);
  644. int omap_dss_get_num_overlays(void);
  645. struct omap_overlay *omap_dss_get_overlay(int num);
  646. struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id);
  647. struct omap_dss_device *omap_dss_find_output(const char *name);
  648. struct omap_dss_device *omap_dss_find_output_by_node(struct device_node *node);
  649. int omapdss_output_set_device(struct omap_dss_device *out,
  650. struct omap_dss_device *dssdev);
  651. int omapdss_output_unset_device(struct omap_dss_device *out);
  652. struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device *dssdev);
  653. struct omap_overlay_manager *omapdss_find_mgr_from_display(struct omap_dss_device *dssdev);
  654. void omapdss_default_get_resolution(struct omap_dss_device *dssdev,
  655. u16 *xres, u16 *yres);
  656. int omapdss_default_get_recommended_bpp(struct omap_dss_device *dssdev);
  657. void omapdss_default_get_timings(struct omap_dss_device *dssdev,
  658. struct omap_video_timings *timings);
  659. typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
  660. int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
  661. int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
  662. u32 dispc_read_irqstatus(void);
  663. void dispc_clear_irqstatus(u32 mask);
  664. u32 dispc_read_irqenable(void);
  665. void dispc_write_irqenable(u32 mask);
  666. int dispc_request_irq(irq_handler_t handler, void *dev_id);
  667. void dispc_free_irq(void *dev_id);
  668. int dispc_runtime_get(void);
  669. void dispc_runtime_put(void);
  670. void dispc_mgr_enable(enum omap_channel channel, bool enable);
  671. bool dispc_mgr_is_enabled(enum omap_channel channel);
  672. u32 dispc_mgr_get_vsync_irq(enum omap_channel channel);
  673. u32 dispc_mgr_get_framedone_irq(enum omap_channel channel);
  674. u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel);
  675. bool dispc_mgr_go_busy(enum omap_channel channel);
  676. void dispc_mgr_go(enum omap_channel channel);
  677. void dispc_mgr_set_lcd_config(enum omap_channel channel,
  678. const struct dss_lcd_mgr_config *config);
  679. void dispc_mgr_set_timings(enum omap_channel channel,
  680. const struct omap_video_timings *timings);
  681. void dispc_mgr_setup(enum omap_channel channel,
  682. const struct omap_overlay_manager_info *info);
  683. int dispc_ovl_check(enum omap_plane plane, enum omap_channel channel,
  684. const struct omap_overlay_info *oi,
  685. const struct omap_video_timings *timings,
  686. int *x_predecim, int *y_predecim);
  687. int dispc_ovl_enable(enum omap_plane plane, bool enable);
  688. bool dispc_ovl_enabled(enum omap_plane plane);
  689. void dispc_ovl_set_channel_out(enum omap_plane plane,
  690. enum omap_channel channel);
  691. int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
  692. bool replication, const struct omap_video_timings *mgr_timings,
  693. bool mem_to_mem);
  694. #define to_dss_driver(x) container_of((x), struct omap_dss_driver, driver)
  695. #define to_dss_device(x) container_of((x), struct omap_dss_device, old_dev)
  696. void omapdss_dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel,
  697. bool enable);
  698. int omapdss_dsi_enable_te(struct omap_dss_device *dssdev, bool enable);
  699. int omapdss_dsi_set_config(struct omap_dss_device *dssdev,
  700. const struct omap_dss_dsi_config *config);
  701. int omap_dsi_update(struct omap_dss_device *dssdev, int channel,
  702. void (*callback)(int, void *), void *data);
  703. int omap_dsi_request_vc(struct omap_dss_device *dssdev, int *channel);
  704. int omap_dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id);
  705. void omap_dsi_release_vc(struct omap_dss_device *dssdev, int channel);
  706. int omapdss_dsi_configure_pins(struct omap_dss_device *dssdev,
  707. const struct omap_dsi_pin_config *pin_cfg);
  708. int omapdss_dsi_display_enable(struct omap_dss_device *dssdev);
  709. void omapdss_dsi_display_disable(struct omap_dss_device *dssdev,
  710. bool disconnect_lanes, bool enter_ulps);
  711. int omapdss_dpi_display_enable(struct omap_dss_device *dssdev);
  712. void omapdss_dpi_display_disable(struct omap_dss_device *dssdev);
  713. void omapdss_dpi_set_timings(struct omap_dss_device *dssdev,
  714. struct omap_video_timings *timings);
  715. int dpi_check_timings(struct omap_dss_device *dssdev,
  716. struct omap_video_timings *timings);
  717. void omapdss_dpi_set_data_lines(struct omap_dss_device *dssdev, int data_lines);
  718. int omapdss_sdi_display_enable(struct omap_dss_device *dssdev);
  719. void omapdss_sdi_display_disable(struct omap_dss_device *dssdev);
  720. void omapdss_sdi_set_timings(struct omap_dss_device *dssdev,
  721. struct omap_video_timings *timings);
  722. void omapdss_sdi_set_datapairs(struct omap_dss_device *dssdev, int datapairs);
  723. int omapdss_rfbi_display_enable(struct omap_dss_device *dssdev);
  724. void omapdss_rfbi_display_disable(struct omap_dss_device *dssdev);
  725. int omap_rfbi_update(struct omap_dss_device *dssdev, void (*callback)(void *),
  726. void *data);
  727. int omap_rfbi_configure(struct omap_dss_device *dssdev);
  728. void omapdss_rfbi_set_size(struct omap_dss_device *dssdev, u16 w, u16 h);
  729. void omapdss_rfbi_set_pixel_size(struct omap_dss_device *dssdev,
  730. int pixel_size);
  731. void omapdss_rfbi_set_data_lines(struct omap_dss_device *dssdev,
  732. int data_lines);
  733. void omapdss_rfbi_set_interface_timings(struct omap_dss_device *dssdev,
  734. struct rfbi_timings *timings);
  735. int omapdss_compat_init(void);
  736. void omapdss_compat_uninit(void);
  737. struct dss_mgr_ops {
  738. int (*connect)(struct omap_overlay_manager *mgr,
  739. struct omap_dss_device *dst);
  740. void (*disconnect)(struct omap_overlay_manager *mgr,
  741. struct omap_dss_device *dst);
  742. void (*start_update)(struct omap_overlay_manager *mgr);
  743. int (*enable)(struct omap_overlay_manager *mgr);
  744. void (*disable)(struct omap_overlay_manager *mgr);
  745. void (*set_timings)(struct omap_overlay_manager *mgr,
  746. const struct omap_video_timings *timings);
  747. void (*set_lcd_config)(struct omap_overlay_manager *mgr,
  748. const struct dss_lcd_mgr_config *config);
  749. int (*register_framedone_handler)(struct omap_overlay_manager *mgr,
  750. void (*handler)(void *), void *data);
  751. void (*unregister_framedone_handler)(struct omap_overlay_manager *mgr,
  752. void (*handler)(void *), void *data);
  753. };
  754. int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
  755. void dss_uninstall_mgr_ops(void);
  756. int dss_mgr_connect(struct omap_overlay_manager *mgr,
  757. struct omap_dss_device *dst);
  758. void dss_mgr_disconnect(struct omap_overlay_manager *mgr,
  759. struct omap_dss_device *dst);
  760. void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
  761. const struct omap_video_timings *timings);
  762. void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr,
  763. const struct dss_lcd_mgr_config *config);
  764. int dss_mgr_enable(struct omap_overlay_manager *mgr);
  765. void dss_mgr_disable(struct omap_overlay_manager *mgr);
  766. void dss_mgr_start_update(struct omap_overlay_manager *mgr);
  767. int dss_mgr_register_framedone_handler(struct omap_overlay_manager *mgr,
  768. void (*handler)(void *), void *data);
  769. void dss_mgr_unregister_framedone_handler(struct omap_overlay_manager *mgr,
  770. void (*handler)(void *), void *data);
  771. static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
  772. {
  773. return dssdev->output;
  774. }
  775. static inline bool omapdss_device_is_enabled(struct omap_dss_device *dssdev)
  776. {
  777. return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
  778. }
  779. #endif