2008-10-17 06:51:47 +08:00
|
|
|
/*
|
|
|
|
* Generic Platform Camera Driver Header
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Magnus Damm
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
2008-07-17 10:02:08 +08:00
|
|
|
#ifndef __SOC_CAMERA_H__
|
|
|
|
#define __SOC_CAMERA_H__
|
|
|
|
|
|
|
|
#include <linux/videodev2.h>
|
2009-08-25 22:06:21 +08:00
|
|
|
#include <media/soc_camera.h>
|
2011-07-27 21:06:09 +08:00
|
|
|
#include <media/v4l2-mediabus.h>
|
2008-07-17 10:02:08 +08:00
|
|
|
|
2009-08-25 22:06:22 +08:00
|
|
|
struct device;
|
|
|
|
|
2008-07-17 10:02:08 +08:00
|
|
|
struct soc_camera_platform_info {
|
2009-08-25 22:28:22 +08:00
|
|
|
const char *format_name;
|
2008-07-17 10:02:08 +08:00
|
|
|
unsigned long format_depth;
|
2009-12-11 22:46:49 +08:00
|
|
|
struct v4l2_mbus_framefmt format;
|
2011-07-27 21:06:09 +08:00
|
|
|
unsigned long mbus_param;
|
|
|
|
enum v4l2_mbus_type mbus_type;
|
2011-07-16 07:03:38 +08:00
|
|
|
struct soc_camera_device *icd;
|
2008-07-17 10:02:08 +08:00
|
|
|
int (*set_capture)(struct soc_camera_platform_info *info, int enable);
|
|
|
|
};
|
|
|
|
|
2011-03-23 15:14:43 +08:00
|
|
|
static inline void soc_camera_platform_release(struct platform_device **pdev)
|
|
|
|
{
|
|
|
|
*pdev = NULL;
|
|
|
|
}
|
|
|
|
|
2011-07-16 07:03:38 +08:00
|
|
|
static inline int soc_camera_platform_add(struct soc_camera_device *icd,
|
2011-03-23 15:14:43 +08:00
|
|
|
struct platform_device **pdev,
|
|
|
|
struct soc_camera_link *plink,
|
|
|
|
void (*release)(struct device *dev),
|
|
|
|
int id)
|
|
|
|
{
|
|
|
|
struct soc_camera_platform_info *info = plink->priv;
|
|
|
|
int ret;
|
|
|
|
|
2011-07-16 07:03:38 +08:00
|
|
|
if (icd->link != plink)
|
2011-03-23 15:14:43 +08:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (*pdev)
|
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
*pdev = platform_device_alloc("soc_camera_platform", id);
|
|
|
|
if (!*pdev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2011-07-16 07:03:38 +08:00
|
|
|
info->icd = icd;
|
2011-03-23 15:14:43 +08:00
|
|
|
|
|
|
|
(*pdev)->dev.platform_data = info;
|
|
|
|
(*pdev)->dev.release = release;
|
|
|
|
|
|
|
|
ret = platform_device_add(*pdev);
|
|
|
|
if (ret < 0) {
|
|
|
|
platform_device_put(*pdev);
|
|
|
|
*pdev = NULL;
|
2011-07-16 07:03:38 +08:00
|
|
|
info->icd = NULL;
|
2011-03-23 15:14:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-07-16 07:03:38 +08:00
|
|
|
static inline void soc_camera_platform_del(const struct soc_camera_device *icd,
|
2011-03-23 15:14:43 +08:00
|
|
|
struct platform_device *pdev,
|
|
|
|
const struct soc_camera_link *plink)
|
|
|
|
{
|
2011-07-16 07:03:38 +08:00
|
|
|
if (icd->link != plink || !pdev)
|
2011-03-23 15:14:43 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
platform_device_unregister(pdev);
|
|
|
|
}
|
|
|
|
|
2008-07-17 10:02:08 +08:00
|
|
|
#endif /* __SOC_CAMERA_H__ */
|