Commit cdce7c0b authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mauro Carvalho Chehab

V4L/DVB (10667): ov772x: setting method to register is changed.

Color format regs array had been used, but it was not easy to understand
what to want to do, and additional bit became complex.
This patch modify this problem.
Signed-off-by: default avatarKuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 2941e81f
...@@ -271,11 +271,13 @@ ...@@ -271,11 +271,13 @@
#define SLCT_QVGA 0x40 /* 1 : QVGA */ #define SLCT_QVGA 0x40 /* 1 : QVGA */
#define ITU656_ON_OFF 0x20 /* ITU656 protocol ON/OFF selection */ #define ITU656_ON_OFF 0x20 /* ITU656 protocol ON/OFF selection */
/* RGB output format control */ /* RGB output format control */
#define FMT_MASK 0x0c /* Mask of color format */
#define FMT_GBR422 0x00 /* 00 : GBR 4:2:2 */ #define FMT_GBR422 0x00 /* 00 : GBR 4:2:2 */
#define FMT_RGB565 0x04 /* 01 : RGB 565 */ #define FMT_RGB565 0x04 /* 01 : RGB 565 */
#define FMT_RGB555 0x08 /* 10 : RGB 555 */ #define FMT_RGB555 0x08 /* 10 : RGB 555 */
#define FMT_RGB444 0x0c /* 11 : RGB 444 */ #define FMT_RGB444 0x0c /* 11 : RGB 444 */
/* Output format control */ /* Output format control */
#define OFMT_MASK 0x03 /* Mask of output format */
#define OFMT_YUV 0x00 /* 00 : YUV */ #define OFMT_YUV 0x00 /* 00 : YUV */
#define OFMT_P_BRAW 0x01 /* 01 : Processed Bayer RAW */ #define OFMT_P_BRAW 0x01 /* 01 : Processed Bayer RAW */
#define OFMT_RGB 0x02 /* 10 : RGB */ #define OFMT_RGB 0x02 /* 10 : RGB */
...@@ -299,7 +301,7 @@ ...@@ -299,7 +301,7 @@
#define GAIN_2x 0x00 /* 000 : 2x */ #define GAIN_2x 0x00 /* 000 : 2x */
#define GAIN_4x 0x10 /* 001 : 4x */ #define GAIN_4x 0x10 /* 001 : 4x */
#define GAIN_8x 0x20 /* 010 : 8x */ #define GAIN_8x 0x20 /* 010 : 8x */
#define GAIN_16x 0x30 /* 011 : 16x */ #define GAIN_16x 0x30 /* 011 : 16x */
#define GAIN_32x 0x40 /* 100 : 32x */ #define GAIN_32x 0x40 /* 100 : 32x */
#define GAIN_64x 0x50 /* 101 : 64x */ #define GAIN_64x 0x50 /* 101 : 64x */
#define GAIN_128x 0x60 /* 110 : 128x */ #define GAIN_128x 0x60 /* 110 : 128x */
...@@ -355,13 +357,6 @@ ...@@ -355,13 +357,6 @@
#define VOSZ_VGA 0xF0 #define VOSZ_VGA 0xF0
#define VOSZ_QVGA 0x78 #define VOSZ_QVGA 0x78
/*
* bit configure (32 bit)
* this is used in struct ov772x_color_format :: option
*/
#define OP_UV 0x00000001
#define OP_SWAP_RGB 0x00000002
/* /*
* ID * ID
*/ */
...@@ -380,8 +375,9 @@ struct regval_list { ...@@ -380,8 +375,9 @@ struct regval_list {
struct ov772x_color_format { struct ov772x_color_format {
char *name; char *name;
__u32 fourcc; __u32 fourcc;
const struct regval_list *regs; u8 dsp3;
unsigned int option; u8 com3;
u8 com7;
}; };
struct ov772x_win_size { struct ov772x_win_size {
...@@ -403,34 +399,6 @@ struct ov772x_priv { ...@@ -403,34 +399,6 @@ struct ov772x_priv {
#define ENDMARKER { 0xff, 0xff } #define ENDMARKER { 0xff, 0xff }
/*
* register setting for color format
*/
static const struct regval_list ov772x_RGB555_regs[] = {
{ COM3, 0x00 },
{ COM7, FMT_RGB555 | OFMT_RGB },
ENDMARKER,
};
static const struct regval_list ov772x_RGB565_regs[] = {
{ COM3, 0x00 },
{ COM7, FMT_RGB565 | OFMT_RGB },
ENDMARKER,
};
static const struct regval_list ov772x_YYUV_regs[] = {
{ COM3, SWAP_YUV },
{ COM7, OFMT_YUV },
ENDMARKER,
};
static const struct regval_list ov772x_UVYY_regs[] = {
{ COM3, 0x00 },
{ COM7, OFMT_YUV },
ENDMARKER,
};
/* /*
* register setting for window size * register setting for window size
*/ */
...@@ -503,34 +471,45 @@ static const struct soc_camera_data_format ov772x_fmt_lists[] = { ...@@ -503,34 +471,45 @@ static const struct soc_camera_data_format ov772x_fmt_lists[] = {
static const struct ov772x_color_format ov772x_cfmts[] = { static const struct ov772x_color_format ov772x_cfmts[] = {
{ {
SETFOURCC(YUYV), SETFOURCC(YUYV),
.regs = ov772x_YYUV_regs, .dsp3 = 0x0,
.com3 = SWAP_YUV,
.com7 = OFMT_YUV,
}, },
{ {
SETFOURCC(YVYU), SETFOURCC(YVYU),
.regs = ov772x_YYUV_regs, .dsp3 = UV_ON,
.option = OP_UV, .com3 = SWAP_YUV,
.com7 = OFMT_YUV,
}, },
{ {
SETFOURCC(UYVY), SETFOURCC(UYVY),
.regs = ov772x_UVYY_regs, .dsp3 = 0x0,
.com3 = 0x0,
.com7 = OFMT_YUV,
}, },
{ {
SETFOURCC(RGB555), SETFOURCC(RGB555),
.regs = ov772x_RGB555_regs, .dsp3 = 0x0,
.option = OP_SWAP_RGB, .com3 = SWAP_RGB,
.com7 = FMT_RGB555 | OFMT_RGB,
}, },
{ {
SETFOURCC(RGB555X), SETFOURCC(RGB555X),
.regs = ov772x_RGB555_regs, .dsp3 = 0x0,
.com3 = 0x0,
.com7 = FMT_RGB555 | OFMT_RGB,
}, },
{ {
SETFOURCC(RGB565), SETFOURCC(RGB565),
.regs = ov772x_RGB565_regs, .dsp3 = 0x0,
.option = OP_SWAP_RGB, .com3 = SWAP_RGB,
.com7 = FMT_RGB565 | OFMT_RGB,
}, },
{ {
SETFOURCC(RGB565X), SETFOURCC(RGB565X),
.regs = ov772x_RGB565_regs, .dsp3 = 0x0,
.com3 = 0x0,
.com7 = FMT_RGB565 | OFMT_RGB,
}, },
}; };
...@@ -738,6 +717,7 @@ static int ov772x_set_fmt(struct soc_camera_device *icd, ...@@ -738,6 +717,7 @@ static int ov772x_set_fmt(struct soc_camera_device *icd,
{ {
struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd);
int ret = -EINVAL; int ret = -EINVAL;
u8 val;
int i; int i;
/* /*
...@@ -763,13 +743,6 @@ static int ov772x_set_fmt(struct soc_camera_device *icd, ...@@ -763,13 +743,6 @@ static int ov772x_set_fmt(struct soc_camera_device *icd,
*/ */
ov772x_reset(priv->client); ov772x_reset(priv->client);
/*
* set color format
*/
ret = ov772x_write_array(priv->client, priv->fmt->regs);
if (ret < 0)
goto ov772x_set_fmt_error;
/* /*
* set size format * set size format
*/ */
...@@ -778,32 +751,34 @@ static int ov772x_set_fmt(struct soc_camera_device *icd, ...@@ -778,32 +751,34 @@ static int ov772x_set_fmt(struct soc_camera_device *icd,
goto ov772x_set_fmt_error; goto ov772x_set_fmt_error;
/* /*
* set COM7 bit ( QVGA or VGA ) * set DSP_CTRL3
*/ */
ret = ov772x_mask_set(priv->client, val = priv->fmt->dsp3;
COM7, SLCT_MASK, priv->win->com7_bit); if (val) {
if (ret < 0)
goto ov772x_set_fmt_error;
/*
* set UV setting
*/
if (priv->fmt->option & OP_UV) {
ret = ov772x_mask_set(priv->client, ret = ov772x_mask_set(priv->client,
DSP_CTRL3, UV_MASK, UV_ON); DSP_CTRL3, UV_MASK, val);
if (ret < 0) if (ret < 0)
goto ov772x_set_fmt_error; goto ov772x_set_fmt_error;
} }
/* /*
* set SWAP setting * set COM3
*/ */
if (priv->fmt->option & OP_SWAP_RGB) { val = priv->fmt->com3;
ret = ov772x_mask_set(priv->client, ret = ov772x_mask_set(priv->client,
COM3, SWAP_MASK, SWAP_RGB); COM3, SWAP_MASK, val);
if (ret < 0) if (ret < 0)
goto ov772x_set_fmt_error; goto ov772x_set_fmt_error;
}
/*
* set COM7
*/
val = priv->win->com7_bit | priv->fmt->com7;
ret = ov772x_mask_set(priv->client,
COM7, (SLCT_MASK | FMT_MASK | OFMT_MASK),
val);
if (ret < 0)
goto ov772x_set_fmt_error;
return ret; return ret;
......
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