blob: 5ef7559b88c19e1da3eaeda94dc1a385cfd76bc8 [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 Pinchart740f8022011-11-29 14:03:17 +010057 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 Pinchart740f8022011-11-29 14:03:17 +010062 int meram_enabled;
63
64 struct mutex open_lock; /* protects the use counter */
65 int use_count;
66
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000067 dma_addr_t dma_handle;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000068 unsigned long pan_offset;
Laurent Pinchart740f8022011-11-29 14:03:17 +010069
70 unsigned long frame_end;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000071 wait_queue_head_t frame_end_wait;
72 struct completion vsync_completion;
Laurent Pinchart9a217e32011-07-13 12:13:47 +020073
Laurent Pinchartfc9e78e2011-11-29 16:05:36 +010074 const struct sh_mobile_lcdc_format_info *format;
Laurent Pinchart9a217e32011-07-13 12:13:47 +020075 unsigned long base_addr_y;
76 unsigned long base_addr_c;
77 unsigned int pitch;
Laurent Pinchartecd29942011-09-18 14:14:46 +020078
79 int (*notify)(struct sh_mobile_lcdc_chan *ch,
80 enum sh_mobile_lcdc_entity_event event,
Laurent Pincharte0c86012011-11-29 01:05:47 +010081 const struct fb_videomode *mode,
82 const struct fb_monspecs *monspec);
Laurent Pinchart740f8022011-11-29 14:03:17 +010083
84 /* Backlight */
85 struct backlight_device *bl;
86
87 /* FB */
88 struct fb_info *info;
89 u32 pseudo_palette[PALETTE_NR];
90 struct {
91 unsigned int width;
92 unsigned int height;
93 struct fb_videomode mode;
94 } display;
95 struct fb_deferred_io defio;
96 struct scatterlist *sglist;
97 int blank_status;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000098};
99
100#endif