[media] gspca: remove needless check before usb_free_coherent()
[linux-2.6/btrfs-unstable.git] / drivers / video / omap / lcd_ams_delta.c
blobed4cad87fbcdb39717e283ed8b764312b745fff3
1 /*
2 * Based on drivers/video/omap/lcd_inn1510.c
4 * LCD panel support for the Amstrad E3 (Delta) videophone.
6 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <linux/module.h>
24 #include <linux/platform_device.h>
25 #include <linux/io.h>
26 #include <linux/delay.h>
27 #include <linux/lcd.h>
28 #include <linux/gpio.h>
30 #include <mach/board-ams-delta.h>
32 #include "omapfb.h"
34 #define AMS_DELTA_DEFAULT_CONTRAST 112
36 #define AMS_DELTA_MAX_CONTRAST 0x00FF
37 #define AMS_DELTA_LCD_POWER 0x0100
40 /* LCD class device section */
42 static int ams_delta_lcd;
44 static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
46 if (power == FB_BLANK_UNBLANK) {
47 if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER)) {
48 omap_writeb(ams_delta_lcd & AMS_DELTA_MAX_CONTRAST,
49 OMAP_PWL_ENABLE);
50 omap_writeb(1, OMAP_PWL_CLK_ENABLE);
51 ams_delta_lcd |= AMS_DELTA_LCD_POWER;
53 } else {
54 if (ams_delta_lcd & AMS_DELTA_LCD_POWER) {
55 omap_writeb(0, OMAP_PWL_ENABLE);
56 omap_writeb(0, OMAP_PWL_CLK_ENABLE);
57 ams_delta_lcd &= ~AMS_DELTA_LCD_POWER;
60 return 0;
63 static int ams_delta_lcd_set_contrast(struct lcd_device *dev, int value)
65 if ((value >= 0) && (value <= AMS_DELTA_MAX_CONTRAST)) {
66 omap_writeb(value, OMAP_PWL_ENABLE);
67 ams_delta_lcd &= ~AMS_DELTA_MAX_CONTRAST;
68 ams_delta_lcd |= value;
70 return 0;
73 #ifdef CONFIG_LCD_CLASS_DEVICE
74 static int ams_delta_lcd_get_power(struct lcd_device *dev)
76 if (ams_delta_lcd & AMS_DELTA_LCD_POWER)
77 return FB_BLANK_UNBLANK;
78 else
79 return FB_BLANK_POWERDOWN;
82 static int ams_delta_lcd_get_contrast(struct lcd_device *dev)
84 if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER))
85 return 0;
87 return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST;
90 static struct lcd_ops ams_delta_lcd_ops = {
91 .get_power = ams_delta_lcd_get_power,
92 .set_power = ams_delta_lcd_set_power,
93 .get_contrast = ams_delta_lcd_get_contrast,
94 .set_contrast = ams_delta_lcd_set_contrast,
96 #endif
99 /* omapfb panel section */
101 static const struct gpio _gpios[] = {
103 .gpio = AMS_DELTA_GPIO_PIN_LCD_VBLEN,
104 .flags = GPIOF_OUT_INIT_LOW,
105 .label = "lcd_vblen",
108 .gpio = AMS_DELTA_GPIO_PIN_LCD_NDISP,
109 .flags = GPIOF_OUT_INIT_LOW,
110 .label = "lcd_ndisp",
114 static int ams_delta_panel_init(struct lcd_panel *panel,
115 struct omapfb_device *fbdev)
117 return gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
120 static void ams_delta_panel_cleanup(struct lcd_panel *panel)
122 gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
125 static int ams_delta_panel_enable(struct lcd_panel *panel)
127 gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1);
128 gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1);
129 return 0;
132 static void ams_delta_panel_disable(struct lcd_panel *panel)
134 gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0);
135 gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0);
138 static unsigned long ams_delta_panel_get_caps(struct lcd_panel *panel)
140 return 0;
143 static struct lcd_panel ams_delta_panel = {
144 .name = "ams-delta",
145 .config = 0,
147 .bpp = 12,
148 .data_lines = 16,
149 .x_res = 480,
150 .y_res = 320,
151 .pixel_clock = 4687,
152 .hsw = 3,
153 .hfp = 1,
154 .hbp = 1,
155 .vsw = 1,
156 .vfp = 0,
157 .vbp = 0,
158 .pcd = 0,
159 .acb = 37,
161 .init = ams_delta_panel_init,
162 .cleanup = ams_delta_panel_cleanup,
163 .enable = ams_delta_panel_enable,
164 .disable = ams_delta_panel_disable,
165 .get_caps = ams_delta_panel_get_caps,
169 /* platform driver section */
171 static int ams_delta_panel_probe(struct platform_device *pdev)
173 struct lcd_device *lcd_device = NULL;
174 #ifdef CONFIG_LCD_CLASS_DEVICE
175 int ret;
177 lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
178 &ams_delta_lcd_ops);
180 if (IS_ERR(lcd_device)) {
181 ret = PTR_ERR(lcd_device);
182 dev_err(&pdev->dev, "failed to register device\n");
183 return ret;
186 platform_set_drvdata(pdev, lcd_device);
187 lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST;
188 #endif
190 ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST);
191 ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
193 omapfb_register_panel(&ams_delta_panel);
194 return 0;
197 static int ams_delta_panel_remove(struct platform_device *pdev)
199 return 0;
202 static int ams_delta_panel_suspend(struct platform_device *pdev,
203 pm_message_t mesg)
205 return 0;
208 static int ams_delta_panel_resume(struct platform_device *pdev)
210 return 0;
213 static struct platform_driver ams_delta_panel_driver = {
214 .probe = ams_delta_panel_probe,
215 .remove = ams_delta_panel_remove,
216 .suspend = ams_delta_panel_suspend,
217 .resume = ams_delta_panel_resume,
218 .driver = {
219 .name = "lcd_ams_delta",
220 .owner = THIS_MODULE,
224 module_platform_driver(ams_delta_panel_driver);