omapdss.h 30 KB

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