blob: b8e47a8bd8abb57418f5a9bbad7eecadce8d074a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +00002#ifndef SH_MOBILE_LCDCFB_H
3#define SH_MOBILE_LCDCFB_H
4
5#include <linux/completion.h>
6#include <linux/fb.h>
Guennadi Liakhovetskidd210502010-09-14 14:48:54 +00007#include <linux/mutex.h>
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +00008#include <linux/wait.h>
9
10/* per-channel registers */
11enum { LDDCKPAT1R, LDDCKPAT2R, LDMT1R, LDMT2R, LDMT3R, LDDFR, LDSM1R,
Damian Hobson-Garcia53b50312011-02-24 05:47:13 +000012 LDSM2R, LDSA1R, LDSA2R, LDMLSR, LDHCNR, LDHSYNR, LDVLNR, LDVSYNR, LDPMR,
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000013 LDHAJR,
14 NR_CH_REGS };
15
16#define PALETTE_NR 16
17
Alexandre Courbot3b0fd9d2011-02-16 03:49:01 +000018struct backlight_device;
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020019struct fb_info;
20struct module;
Laurent Pincharte34d0bb2011-09-18 12:21:17 +020021struct sh_mobile_lcdc_chan;
Laurent Pinchartfc9e78e2011-11-29 16:05:36 +010022struct sh_mobile_lcdc_entity;
23struct sh_mobile_lcdc_format_info;
24struct sh_mobile_lcdc_priv;
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020025
Laurent Pinchart458981c2011-11-28 23:19:59 +010026#define SH_MOBILE_LCDC_DISPLAY_DISCONNECTED 0
27#define SH_MOBILE_LCDC_DISPLAY_CONNECTED 1
28
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020029struct sh_mobile_lcdc_entity_ops {
30 /* Display */
Laurent Pinchart5864ace2011-09-18 12:26:50 +020031 int (*display_on)(struct sh_mobile_lcdc_entity *entity);
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020032 void (*display_off)(struct sh_mobile_lcdc_entity *entity);
33};
34
Laurent Pinchartecd29942011-09-18 14:14:46 +020035enum sh_mobile_lcdc_entity_event {
36 SH_MOBILE_LCDC_EVENT_DISPLAY_CONNECT,
37 SH_MOBILE_LCDC_EVENT_DISPLAY_DISCONNECT,
38 SH_MOBILE_LCDC_EVENT_DISPLAY_MODE,
39};
40
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020041struct sh_mobile_lcdc_entity {
42 struct module *owner;
43 const struct sh_mobile_lcdc_entity_ops *ops;
Laurent Pincharte34d0bb2011-09-18 12:21:17 +020044 struct sh_mobile_lcdc_chan *lcdc;
Laurent Pinchart13f80ee2011-11-29 01:46:12 +010045 struct fb_videomode def_mode;
Laurent Pinchartd2ccdc82011-09-11 18:15:36 +020046};
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000047
Laurent Pinchart9a217e32011-07-13 12:13:47 +020048/*
49 * struct sh_mobile_lcdc_chan - LCDC display channel
50 *
Laurent Pincharta4aa25f2012-03-15 18:15:37 +010051 * @pan_y_offset: Panning linear offset in bytes (luma component)
Laurent Pinchart9a217e32011-07-13 12:13:47 +020052 * @base_addr_y: Frame buffer viewport base address (luma component)
53 * @base_addr_c: Frame buffer viewport base address (chroma component)
54 * @pitch: Frame buffer line pitch
55 */
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000056struct sh_mobile_lcdc_chan {
57 struct sh_mobile_lcdc_priv *lcdc;
Laurent Pinchart9a2985e2011-09-11 22:59:04 +020058 struct sh_mobile_lcdc_entity *tx_dev;
Laurent Pinchartb5ef9672011-11-22 00:56:58 +010059 const struct sh_mobile_lcdc_chan_cfg *cfg;
Laurent Pinchart9a2985e2011-09-11 22:59:04 +020060
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +000061 unsigned long *reg_offs;
62 unsigned long ldmt1r_value;
63 unsigned long enabled; /* ME and SE in LDCNT2R */
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;
Laurent Pinchart656d4f32012-08-15 18:10:03 +020097 unsigned int bl_brightness;
Laurent Pinchart740f8022011-11-29 14:03:17 +010098
99 /* FB */
100 struct fb_info *info;
101 u32 pseudo_palette[PALETTE_NR];
102 struct {
103 unsigned int width;
104 unsigned int height;
105 struct fb_videomode mode;
106 } display;
107 struct fb_deferred_io defio;
108 struct scatterlist *sglist;
109 int blank_status;
Guennadi Liakhovetski6de9edd2010-09-03 07:20:23 +0000110};
111
112#endif