blob: 5c3bddd2cb7293871933fc057c8178678621a8a4 [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 *
50 * @base_addr_y: Frame buffer viewport base address (luma component)
51 * @base_addr_c: Frame buffer viewport base address (chroma component)
52 * @pitch: Frame buffer line pitch
53 */
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000054struct sh_mobile_lcdc_chan {
55 struct sh_mobile_lcdc_priv *lcdc;
Laurent Pinchart9a2985e2011-09-11 22:59:04 +020056 struct sh_mobile_lcdc_entity *tx_dev;
Laurent Pinchartb5ef9672011-11-22 00:56:58 +010057 const struct sh_mobile_lcdc_chan_cfg *cfg;
Laurent Pinchart9a2985e2011-09-11 22:59:04 +020058
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000059 unsigned long *reg_offs;
60 unsigned long ldmt1r_value;
61 unsigned long enabled; /* ME and SE in LDCNT2R */
Laurent Pinchart48110052011-12-12 16:36:13 +010062 void *meram;
Laurent Pinchart740f8022011-11-29 14:03:17 +010063
64 struct mutex open_lock; /* protects the use counter */
65 int use_count;
66
Laurent Pincharta67f3792011-11-29 14:37:35 +010067 void *fb_mem;
68 unsigned long fb_size;
Laurent Pinchartb5ef9672011-11-22 00:56:58 +010069
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000070 dma_addr_t dma_handle;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000071 unsigned long pan_offset;
Laurent Pinchart740f8022011-11-29 14:03:17 +010072
73 unsigned long frame_end;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000074 wait_queue_head_t frame_end_wait;
75 struct completion vsync_completion;
Laurent Pinchart9a217e32011-07-13 12:13:47 +020076
Laurent Pinchartfc9e78e2011-11-29 16:05:36 +010077 const struct sh_mobile_lcdc_format_info *format;
Laurent Pinchart58f03d92011-11-30 23:07:30 +010078 u32 colorspace;
79 unsigned int xres;
80 unsigned int xres_virtual;
81 unsigned int yres;
82 unsigned int yres_virtual;
83 unsigned int pitch;
84
Laurent Pinchart9a217e32011-07-13 12:13:47 +020085 unsigned long base_addr_y;
86 unsigned long base_addr_c;
Laurent Pinchart72c04af2012-05-18 10:58:26 +020087 unsigned int line_size;
Laurent Pinchartecd29942011-09-18 14:14:46 +020088
89 int (*notify)(struct sh_mobile_lcdc_chan *ch,
90 enum sh_mobile_lcdc_entity_event event,
Laurent Pincharte0c86012011-11-29 01:05:47 +010091 const struct fb_videomode *mode,
92 const struct fb_monspecs *monspec);
Laurent Pinchart740f8022011-11-29 14:03:17 +010093
94 /* Backlight */
95 struct backlight_device *bl;
96
97 /* FB */
98 struct fb_info *info;
99 u32 pseudo_palette[PALETTE_NR];
100 struct {
101 unsigned int width;
102 unsigned int height;
103 struct fb_videomode mode;
104 } display;
105 struct fb_deferred_io defio;
106 struct scatterlist *sglist;
107 int blank_status;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +0000108};
109
110#endif