blob: 0f92f6544b94907a7a51b503101c07a705421aed [file] [log] [blame]
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +00001#ifndef SH_MOBILE_LCDCFB_H
2#define SH_MOBILE_LCDCFB_H
3
4#include <linux/completion.h>
5#include <linux/fb.h>
Guennadi Liakhovetskidd210502010-09-14 14:48:54 +00006#include <linux/mutex.h>
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +00007#include <linux/wait.h>
8
9/* per-channel registers */
10enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R,
Damian Hobson-Garcia53b50312011-02-24 05:47:13 +000011 LDSM2R, LDSA1R, LDSA2R, LDMLSR, LDHCNR, LDHSYNR, LDVLNR, LDVSYNR, LDPMR,
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000012 LDHAJR,
13 NR_CH_REGS };
14
15#define PALETTE_NR 16
16
Alexandre Courbot3b0fd9d2011-02-16 03:49:01 +000017struct backlight_device;
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020018struct fb_info;
19struct module;
Laurent Pincharte34d0bb2011-09-18 12:21:17 +020020struct sh_mobile_lcdc_chan;
Laurent Pinchartfc9e78e2011-11-29 16:05:36 +010021struct sh_mobile_lcdc_entity;
22struct sh_mobile_lcdc_format_info;
23struct sh_mobile_lcdc_priv;
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020024
Laurent Pinchart458981c2011-11-28 23:19:59 +010025#define SH_MOBILE_LCDC_DISPLAY_DISCONNECTED 0
26#define SH_MOBILE_LCDC_DISPLAY_CONNECTED 1
27
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020028struct sh_mobile_lcdc_entity_ops {
29 /* Display */
Laurent Pinchart5864ace2011-09-18 12:26:50 +020030 int (*display_on)(struct sh_mobile_lcdc_entity *entity);
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020031 void (*display_off)(struct sh_mobile_lcdc_entity *entity);
32};
33
Laurent Pinchartecd29942011-09-18 14:14:46 +020034enum sh_mobile_lcdc_entity_event {
35 SH_MOBILE_LCDC_EVENT_DISPLAY_CONNECT,
36 SH_MOBILE_LCDC_EVENT_DISPLAY_DISCONNECT,
37 SH_MOBILE_LCDC_EVENT_DISPLAY_MODE,
38};
39
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020040struct sh_mobile_lcdc_entity {
41 struct module *owner;
42 const struct sh_mobile_lcdc_entity_ops *ops;
Laurent Pincharte34d0bb2011-09-18 12:21:17 +020043 struct sh_mobile_lcdc_chan *lcdc;
Laurent Pinchart13f80ee2011-11-29 01:46:12 +010044 struct fb_videomode def_mode;
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020045};
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000046
Laurent Pinchart9a217e32011-07-13 12:13:47 +020047/*
48 * struct sh_mobile_lcdc_chan - LCDC display channel
49 *
Laurent Pincharta4aa25f2012-03-15 18:15:37 +010050 * @pan_y_offset: Panning linear offset in bytes (luma component)
Laurent Pinchart9a217e32011-07-13 12:13:47 +020051 * @base_addr_y: Frame buffer viewport base address (luma component)
52 * @base_addr_c: Frame buffer viewport base address (chroma component)
53 * @pitch: Frame buffer line pitch
54 */
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000055struct sh_mobile_lcdc_chan {
56 struct sh_mobile_lcdc_priv *lcdc;
Laurent Pinchart9a2985e2011-09-11 22:59:04 +020057 struct sh_mobile_lcdc_entity *tx_dev;
Laurent Pinchartb5ef9672011-11-22 00:56:58 +010058 const struct sh_mobile_lcdc_chan_cfg *cfg;
Laurent Pinchart9a2985e2011-09-11 22:59:04 +020059
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000060 unsigned long *reg_offs;
61 unsigned long ldmt1r_value;
62 unsigned long enabled; /* ME and SE in LDCNT2R */
Laurent Pinchart4a2371772012-03-15 12:40:47 +010063 void *cache;
Laurent Pinchart740f8022011-11-29 14:03:17 +010064
65 struct mutex open_lock; /* protects the use counter */
66 int use_count;
67
Laurent Pincharta67f3792011-11-29 14:37:35 +010068 void *fb_mem;
69 unsigned long fb_size;
Laurent Pinchartb5ef9672011-11-22 00:56:58 +010070
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000071 dma_addr_t dma_handle;
Laurent Pincharta4aa25f2012-03-15 18:15:37 +010072 unsigned long pan_y_offset;
Laurent Pinchart740f8022011-11-29 14:03:17 +010073
74 unsigned long frame_end;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000075 wait_queue_head_t frame_end_wait;
76 struct completion vsync_completion;
Laurent Pinchart9a217e32011-07-13 12:13:47 +020077
Laurent Pinchartfc9e78e2011-11-29 16:05:36 +010078 const struct sh_mobile_lcdc_format_info *format;
Laurent Pinchart58f03d92011-11-30 23:07:30 +010079 u32 colorspace;
80 unsigned int xres;
81 unsigned int xres_virtual;
82 unsigned int yres;
83 unsigned int yres_virtual;
84 unsigned int pitch;
85
Laurent Pinchart9a217e32011-07-13 12:13:47 +020086 unsigned long base_addr_y;
87 unsigned long base_addr_c;
Laurent Pinchart72c04af2012-05-18 10:58:26 +020088 unsigned int line_size;
Laurent Pinchartecd29942011-09-18 14:14:46 +020089
90 int (*notify)(struct sh_mobile_lcdc_chan *ch,
91 enum sh_mobile_lcdc_entity_event event,
Laurent Pincharte0c86012011-11-29 01:05:47 +010092 const struct fb_videomode *mode,
93 const struct fb_monspecs *monspec);
Laurent Pinchart740f8022011-11-29 14:03:17 +010094
95 /* Backlight */
96 struct backlight_device *bl;
97
98 /* FB */
99 struct fb_info *info;
100 u32 pseudo_palette[PALETTE_NR];
101 struct {
102 unsigned int width;
103 unsigned int height;
104 struct fb_videomode mode;
105 } display;
106 struct fb_deferred_io defio;
107 struct scatterlist *sglist;
108 int blank_status;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +0000109};
110
111#endif