aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/davinci/vpif.c
diff options
context:
space:
mode:
authorMuralidharan Karicheri <m-karicheri2@ti.com>2009-09-16 13:31:20 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:19:40 -0400
commitd28a6df608fa4fade5e1d7e22d1be652a71412e0 (patch)
treea2970332a69882772fb7daa456d1cb3fef13183b /drivers/media/video/davinci/vpif.c
parent6ffefff5a9e76c2e9cb5081e219a7a6a4a5eee9f (diff)
V4L/DVB (12906d): V4L : vpif updates for DM6467 vpif capture driver
Following changes done for vpif driver to support vpif capture:- 1) Current version of display driver defined vpif register space as part for vpif display platform driver resource This is not correct since vpif is common across capture and display drivers. So the resource iomap function is moved to this module 2) Since there are common registers, a spinlock is added for mutual exclusion. This has incorporated comments against version v0 of the patch series Resending to merge to V4L linux-next Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Muralidharan Karicheri <m-karicheri2@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/davinci/vpif.c')
-rw-r--r--drivers/media/video/davinci/vpif.c76
1 files changed, 69 insertions, 7 deletions
diff --git a/drivers/media/video/davinci/vpif.c b/drivers/media/video/davinci/vpif.c
index aa771268a5a5..3b8eac31ecae 100644
--- a/drivers/media/video/davinci/vpif.c
+++ b/drivers/media/video/davinci/vpif.c
@@ -19,7 +19,11 @@
19 19
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/platform_device.h>
23#include <linux/spinlock.h>
22#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/io.h>
26#include <mach/hardware.h>
23 27
24#include "vpif.h" 28#include "vpif.h"
25 29
@@ -31,6 +35,12 @@ MODULE_LICENSE("GPL");
31#define VPIF_CH2_MAX_MODES (15) 35#define VPIF_CH2_MAX_MODES (15)
32#define VPIF_CH3_MAX_MODES (02) 36#define VPIF_CH3_MAX_MODES (02)
33 37
38static resource_size_t res_len;
39static struct resource *res;
40spinlock_t vpif_lock;
41
42void __iomem *vpif_base;
43
34static inline void vpif_wr_bit(u32 reg, u32 bit, u32 val) 44static inline void vpif_wr_bit(u32 reg, u32 bit, u32 val)
35{ 45{
36 if (val) 46 if (val)
@@ -151,17 +161,17 @@ static void config_vpif_params(struct vpif_params *vpifparams,
151 else if (config->capture_format) { 161 else if (config->capture_format) {
152 /* Set the polarity of various pins */ 162 /* Set the polarity of various pins */
153 vpif_wr_bit(reg, VPIF_CH_FID_POLARITY_BIT, 163 vpif_wr_bit(reg, VPIF_CH_FID_POLARITY_BIT,
154 vpifparams->params.raw_params.fid_pol); 164 vpifparams->iface.fid_pol);
155 vpif_wr_bit(reg, VPIF_CH_V_VALID_POLARITY_BIT, 165 vpif_wr_bit(reg, VPIF_CH_V_VALID_POLARITY_BIT,
156 vpifparams->params.raw_params.vd_pol); 166 vpifparams->iface.vd_pol);
157 vpif_wr_bit(reg, VPIF_CH_H_VALID_POLARITY_BIT, 167 vpif_wr_bit(reg, VPIF_CH_H_VALID_POLARITY_BIT,
158 vpifparams->params.raw_params.hd_pol); 168 vpifparams->iface.hd_pol);
159 169
160 value = regr(reg); 170 value = regr(reg);
161 /* Set data width */ 171 /* Set data width */
162 value &= ((~(unsigned int)(0x3)) << 172 value &= ((~(unsigned int)(0x3)) <<
163 VPIF_CH_DATA_WIDTH_BIT); 173 VPIF_CH_DATA_WIDTH_BIT);
164 value |= ((vpifparams->params.raw_params.data_sz) << 174 value |= ((vpifparams->params.data_sz) <<
165 VPIF_CH_DATA_WIDTH_BIT); 175 VPIF_CH_DATA_WIDTH_BIT);
166 regw(value, reg); 176 regw(value, reg);
167 } 177 }
@@ -227,8 +237,60 @@ int vpif_channel_getfid(u8 channel_id)
227} 237}
228EXPORT_SYMBOL(vpif_channel_getfid); 238EXPORT_SYMBOL(vpif_channel_getfid);
229 239
230void vpif_base_addr_init(void __iomem *base) 240static int __init vpif_probe(struct platform_device *pdev)
241{
242 int status = 0;
243
244 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
245 if (!res)
246 return -ENOENT;
247
248 res_len = res->end - res->start + 1;
249
250 res = request_mem_region(res->start, res_len, res->name);
251 if (!res)
252 return -EBUSY;
253
254 vpif_base = ioremap(res->start, res_len);
255 if (!vpif_base) {
256 status = -EBUSY;
257 goto fail;
258 }
259
260 spin_lock_init(&vpif_lock);
261 dev_info(&pdev->dev, "vpif probe success\n");
262 return 0;
263
264fail:
265 release_mem_region(res->start, res_len);
266 return status;
267}
268
269static int vpif_remove(struct platform_device *pdev)
231{ 270{
232 vpif_base = base; 271 iounmap(vpif_base);
272 release_mem_region(res->start, res_len);
273 return 0;
233} 274}
234EXPORT_SYMBOL(vpif_base_addr_init); 275
276static struct platform_driver vpif_driver = {
277 .driver = {
278 .name = "vpif",
279 .owner = THIS_MODULE,
280 },
281 .remove = __devexit_p(vpif_remove),
282 .probe = vpif_probe,
283};
284
285static void vpif_exit(void)
286{
287 platform_driver_unregister(&vpif_driver);
288}
289
290static int __init vpif_init(void)
291{
292 return platform_driver_register(&vpif_driver);
293}
294subsys_initcall(vpif_init);
295module_exit(vpif_exit);
296