omapdss.h 29 KB

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