Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 124551
b: refs/heads/master
c: 9414de3
h: refs/heads/master
i:
  124549: 7ea0d5d
  124547: d1c9c3b
  124543: 8c744bc
v: v3
  • Loading branch information
Magnus Damm authored and Mauro Carvalho Chehab committed Dec 30, 2008
1 parent 3feab67 commit 56cc18e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 91962fa713bd8bf47434b02ac661fdc201365fa5
refs/heads/master: 9414de39e8e07d90bdb6524be501fae0e013d37b
83 changes: 57 additions & 26 deletions trunk/drivers/media/video/sh_mobile_ceu_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,7 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd,
return 0;
}

static int sh_mobile_ceu_try_bus_param(struct soc_camera_device *icd,
__u32 pixfmt)
static int sh_mobile_ceu_try_bus_param(struct soc_camera_device *icd)
{
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct sh_mobile_ceu_dev *pcdev = ici->priv;
Expand All @@ -450,45 +449,76 @@ static int sh_mobile_ceu_try_bus_param(struct soc_camera_device *icd,
return 0;
}

static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
struct soc_camera_format_xlate *xlate)
{
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
int ret;
int formats = 0;

ret = sh_mobile_ceu_try_bus_param(icd);
if (ret < 0)
return 0;

switch (icd->formats[idx].fourcc) {
default:
/* Generic pass-through */
formats++;
if (xlate) {
xlate->host_fmt = icd->formats + idx;
xlate->cam_fmt = icd->formats + idx;
xlate->buswidth = icd->formats[idx].depth;
xlate++;
dev_dbg(&ici->dev,
"Providing format %s in pass-through mode\n",
icd->formats[idx].name);
}
}

return formats;
}

static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
__u32 pixfmt, struct v4l2_rect *rect)
{
const struct soc_camera_data_format *cam_fmt = NULL;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
const struct soc_camera_format_xlate *xlate;
int ret;

/*
* TODO: find a suitable supported by the SoC output format, check
* whether the sensor supports one of acceptable input formats.
*/
if (pixfmt) {
cam_fmt = soc_camera_format_by_fourcc(icd, pixfmt);
if (!cam_fmt)
return -EINVAL;
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
dev_warn(&ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL;
}

ret = icd->ops->set_fmt(icd, pixfmt, rect);
if (pixfmt && !ret)
icd->current_fmt = cam_fmt;
switch (pixfmt) {
case 0: /* Only geometry change */
ret = icd->ops->set_fmt(icd, pixfmt, rect);
break;
default:
ret = icd->ops->set_fmt(icd, xlate->cam_fmt->fourcc, rect);
}

if (pixfmt && !ret) {
icd->buswidth = xlate->buswidth;
icd->current_fmt = xlate->host_fmt;
}

return ret;
}

static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
struct v4l2_format *f)
{
const struct soc_camera_data_format *cam_fmt;
int ret = sh_mobile_ceu_try_bus_param(icd, f->fmt.pix.pixelformat);

if (ret < 0)
return ret;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
const struct soc_camera_format_xlate *xlate;
__u32 pixfmt = f->fmt.pix.pixelformat;

/*
* TODO: find a suitable supported by the SoC output format, check
* whether the sensor supports one of acceptable input formats.
*/
cam_fmt = soc_camera_format_by_fourcc(icd, f->fmt.pix.pixelformat);
if (!cam_fmt)
xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
if (!xlate) {
dev_warn(&ici->dev, "Format %x not found\n", pixfmt);
return -EINVAL;
}

/* FIXME: calculate using depth and bus width */

Expand All @@ -504,7 +534,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
f->fmt.pix.height &= ~0x03;

f->fmt.pix.bytesperline = f->fmt.pix.width *
DIV_ROUND_UP(cam_fmt->depth, 8);
DIV_ROUND_UP(xlate->host_fmt->depth, 8);
f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;

/* limit to sensor capabilities */
Expand Down Expand Up @@ -576,6 +606,7 @@ static struct soc_camera_host_ops sh_mobile_ceu_host_ops = {
.owner = THIS_MODULE,
.add = sh_mobile_ceu_add_device,
.remove = sh_mobile_ceu_remove_device,
.get_formats = sh_mobile_ceu_get_formats,
.set_fmt = sh_mobile_ceu_set_fmt,
.try_fmt = sh_mobile_ceu_try_fmt,
.reqbufs = sh_mobile_ceu_reqbufs,
Expand Down

0 comments on commit 56cc18e

Please sign in to comment.