Commit 2ad90b71 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Mauro Carvalho Chehab

[media] V4L: tw9910: remove a not really implemented cropping support

Cropping is not really correctly implemented by this driver and only
needlessly obfuscates the code. Remove it.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 022e52cf
...@@ -203,6 +203,10 @@ ...@@ -203,6 +203,10 @@
#define RTSEL_FIELD 0x06 /* 0110 = FIELD */ #define RTSEL_FIELD 0x06 /* 0110 = FIELD */
#define RTSEL_RTCO 0x07 /* 0111 = RTCO ( Real Time Control ) */ #define RTSEL_RTCO 0x07 /* 0111 = RTCO ( Real Time Control ) */
/* HSYNC start and end are constant for now */
#define HSYNC_START 0x0260
#define HSYNC_END 0x0300
/* /*
* structure * structure
*/ */
...@@ -220,18 +224,6 @@ struct tw9910_scale_ctrl { ...@@ -220,18 +224,6 @@ struct tw9910_scale_ctrl {
u16 vscale; u16 vscale;
}; };
struct tw9910_cropping_ctrl {
u16 vdelay;
u16 vactive;
u16 hdelay;
u16 hactive;
};
struct tw9910_hsync_ctrl {
u16 start;
u16 end;
};
struct tw9910_priv { struct tw9910_priv {
struct v4l2_subdev subdev; struct v4l2_subdev subdev;
struct tw9910_video_info *info; struct tw9910_video_info *info;
...@@ -329,11 +321,6 @@ static const struct tw9910_scale_ctrl tw9910_pal_scales[] = { ...@@ -329,11 +321,6 @@ static const struct tw9910_scale_ctrl tw9910_pal_scales[] = {
}, },
}; };
static const struct tw9910_hsync_ctrl tw9910_hsync_ctrl = {
.start = 0x0260,
.end = 0x0300,
};
/* /*
* general function * general function
*/ */
...@@ -378,21 +365,20 @@ static int tw9910_set_scale(struct i2c_client *client, ...@@ -378,21 +365,20 @@ static int tw9910_set_scale(struct i2c_client *client,
return ret; return ret;
} }
static int tw9910_set_hsync(struct i2c_client *client, static int tw9910_set_hsync(struct i2c_client *client)
const struct tw9910_hsync_ctrl *hsync)
{ {
struct tw9910_priv *priv = to_tw9910(client); struct tw9910_priv *priv = to_tw9910(client);
int ret; int ret;
/* bit 10 - 3 */ /* bit 10 - 3 */
ret = i2c_smbus_write_byte_data(client, HSBEGIN, ret = i2c_smbus_write_byte_data(client, HSBEGIN,
(hsync->start & 0x07F8) >> 3); (HSYNC_START & 0x07F8) >> 3);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* bit 10 - 3 */ /* bit 10 - 3 */
ret = i2c_smbus_write_byte_data(client, HSEND, ret = i2c_smbus_write_byte_data(client, HSEND,
(hsync->end & 0x07F8) >> 3); (HSYNC_END & 0x07F8) >> 3);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -400,8 +386,8 @@ static int tw9910_set_hsync(struct i2c_client *client, ...@@ -400,8 +386,8 @@ static int tw9910_set_hsync(struct i2c_client *client,
/* bit 2 - 0 */ /* bit 2 - 0 */
if (1 == priv->revision) if (1 == priv->revision)
ret = tw9910_mask_set(client, HSLOWCTL, 0x77, ret = tw9910_mask_set(client, HSLOWCTL, 0x77,
(hsync->start & 0x0007) << 4 | (HSYNC_START & 0x0007) << 4 |
(hsync->end & 0x0007)); (HSYNC_END & 0x0007));
return ret; return ret;
} }
...@@ -433,8 +419,8 @@ static int tw9910_power(struct i2c_client *client, int enable) ...@@ -433,8 +419,8 @@ static int tw9910_power(struct i2c_client *client, int enable)
return tw9910_mask_set(client, ACNTL2, ACNTL2_PDN_MASK, acntl2); return tw9910_mask_set(client, ACNTL2, ACNTL2_PDN_MASK, acntl2);
} }
static const struct tw9910_scale_ctrl* static const struct tw9910_scale_ctrl *tw9910_select_norm(struct soc_camera_device *icd,
tw9910_select_norm(struct soc_camera_device *icd, u32 width, u32 height) u32 width, u32 height)
{ {
const struct tw9910_scale_ctrl *scale; const struct tw9910_scale_ctrl *scale;
const struct tw9910_scale_ctrl *ret = NULL; const struct tw9910_scale_ctrl *ret = NULL;
...@@ -510,10 +496,13 @@ static int tw9910_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -510,10 +496,13 @@ static int tw9910_s_stream(struct v4l2_subdev *sd, int enable)
static int tw9910_set_bus_param(struct soc_camera_device *icd, static int tw9910_set_bus_param(struct soc_camera_device *icd,
unsigned long flags) unsigned long flags)
{ {
struct soc_camera_link *icl = to_soc_camera_link(icd);
struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
struct i2c_client *client = v4l2_get_subdevdata(sd); struct i2c_client *client = v4l2_get_subdevdata(sd);
u8 val = VSSL_VVALID | HSSL_DVALID; u8 val = VSSL_VVALID | HSSL_DVALID;
flags = soc_camera_apply_sensor_flags(icl, flags);
/* /*
* set OUTCTR1 * set OUTCTR1
* *
...@@ -600,9 +589,8 @@ static int tw9910_s_register(struct v4l2_subdev *sd, ...@@ -600,9 +589,8 @@ static int tw9910_s_register(struct v4l2_subdev *sd,
} }
#endif #endif
static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) static int tw9910_set_frame(struct v4l2_subdev *sd, u32 *width, u32 *height)
{ {
struct v4l2_rect *rect = &a->c;
struct i2c_client *client = v4l2_get_subdevdata(sd); struct i2c_client *client = v4l2_get_subdevdata(sd);
struct tw9910_priv *priv = to_tw9910(client); struct tw9910_priv *priv = to_tw9910(client);
struct soc_camera_device *icd = client->dev.platform_data; struct soc_camera_device *icd = client->dev.platform_data;
...@@ -612,7 +600,7 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) ...@@ -612,7 +600,7 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
/* /*
* select suitable norm * select suitable norm
*/ */
priv->scale = tw9910_select_norm(icd, rect->width, rect->height); priv->scale = tw9910_select_norm(icd, *width, *height);
if (!priv->scale) if (!priv->scale)
goto tw9910_set_fmt_error; goto tw9910_set_fmt_error;
...@@ -670,14 +658,12 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) ...@@ -670,14 +658,12 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
/* /*
* set hsync * set hsync
*/ */
ret = tw9910_set_hsync(client, &tw9910_hsync_ctrl); ret = tw9910_set_hsync(client);
if (ret < 0) if (ret < 0)
goto tw9910_set_fmt_error; goto tw9910_set_fmt_error;
rect->width = priv->scale->width; *width = priv->scale->width;
rect->height = priv->scale->height; *height = priv->scale->height;
rect->left = 0;
rect->top = 0;
return ret; return ret;
...@@ -692,27 +678,17 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) ...@@ -692,27 +678,17 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int tw9910_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) static int tw9910_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
{ {
struct i2c_client *client = v4l2_get_subdevdata(sd); struct i2c_client *client = v4l2_get_subdevdata(sd);
struct tw9910_priv *priv = to_tw9910(client); struct soc_camera_device *icd = client->dev.platform_data;
if (!priv->scale) {
int ret;
struct v4l2_crop crop = {
.c = {
.left = 0,
.top = 0,
.width = 640,
.height = 480,
},
};
ret = tw9910_s_crop(sd, &crop);
if (ret < 0)
return ret;
}
a->c.left = 0; a->c.left = 0;
a->c.top = 0; a->c.top = 0;
a->c.width = priv->scale->width; if (icd->vdev->current_norm & V4L2_STD_NTSC) {
a->c.height = priv->scale->height; a->c.width = 640;
a->c.height = 480;
} else {
a->c.width = 768;
a->c.height = 576;
}
a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
return 0; return 0;
...@@ -720,14 +696,19 @@ static int tw9910_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) ...@@ -720,14 +696,19 @@ static int tw9910_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
static int tw9910_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) static int tw9910_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
{ {
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct soc_camera_device *icd = client->dev.platform_data;
a->bounds.left = 0; a->bounds.left = 0;
a->bounds.top = 0; a->bounds.top = 0;
if (icd->vdev->current_norm & V4L2_STD_NTSC) {
a->bounds.width = 640;
a->bounds.height = 480;
} else {
a->bounds.width = 768; a->bounds.width = 768;
a->bounds.height = 576; a->bounds.height = 576;
a->defrect.left = 0; }
a->defrect.top = 0; a->defrect = a->bounds;
a->defrect.width = 640;
a->defrect.height = 480;
a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
a->pixelaspect.numerator = 1; a->pixelaspect.numerator = 1;
a->pixelaspect.denominator = 1; a->pixelaspect.denominator = 1;
...@@ -743,15 +724,8 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd, ...@@ -743,15 +724,8 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd,
if (!priv->scale) { if (!priv->scale) {
int ret; int ret;
struct v4l2_crop crop = { u32 width = 640, height = 480;
.c = { ret = tw9910_set_frame(sd, &width, &height);
.left = 0,
.top = 0,
.width = 640,
.height = 480,
},
};
ret = tw9910_s_crop(sd, &crop);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
...@@ -768,17 +742,7 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd, ...@@ -768,17 +742,7 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd,
static int tw9910_s_fmt(struct v4l2_subdev *sd, static int tw9910_s_fmt(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *mf) struct v4l2_mbus_framefmt *mf)
{ {
struct i2c_client *client = v4l2_get_subdevdata(sd); u32 width = mf->width, height = mf->height;
struct tw9910_priv *priv = to_tw9910(client);
/* See tw9910_s_crop() - no proper cropping support */
struct v4l2_crop a = {
.c = {
.left = 0,
.top = 0,
.width = mf->width,
.height = mf->height,
},
};
int ret; int ret;
WARN_ON(mf->field != V4L2_FIELD_ANY && WARN_ON(mf->field != V4L2_FIELD_ANY &&
...@@ -792,10 +756,10 @@ static int tw9910_s_fmt(struct v4l2_subdev *sd, ...@@ -792,10 +756,10 @@ static int tw9910_s_fmt(struct v4l2_subdev *sd,
mf->colorspace = V4L2_COLORSPACE_JPEG; mf->colorspace = V4L2_COLORSPACE_JPEG;
ret = tw9910_s_crop(sd, &a); ret = tw9910_set_frame(sd, &width, &height);
if (!ret) { if (!ret) {
mf->width = priv->scale->width; mf->width = width;
mf->height = priv->scale->height; mf->height = height;
} }
return ret; return ret;
} }
...@@ -905,7 +869,6 @@ static struct v4l2_subdev_video_ops tw9910_subdev_video_ops = { ...@@ -905,7 +869,6 @@ static struct v4l2_subdev_video_ops tw9910_subdev_video_ops = {
.try_mbus_fmt = tw9910_try_fmt, .try_mbus_fmt = tw9910_try_fmt,
.cropcap = tw9910_cropcap, .cropcap = tw9910_cropcap,
.g_crop = tw9910_g_crop, .g_crop = tw9910_g_crop,
.s_crop = tw9910_s_crop,
.enum_mbus_fmt = tw9910_enum_fmt, .enum_mbus_fmt = tw9910_enum_fmt,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment