Commit 3560f6dc authored by 吴智聪(John Wu)'s avatar 吴智聪(John Wu)

clean up code and fix some typo in vpfe and tvp7000 code

parent a5555708
This diff is collapsed.
...@@ -521,7 +521,7 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter, ...@@ -521,7 +521,7 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter,
static inline int tvp7000_read_reg(u8 reg); static inline int tvp7000_read_reg(u8 reg);
static inline int tvp7000_write_reg(u8 reg, u8 value); static inline int tvp7000_write_reg(u8 reg, u8 value);
static int tvp7000_setup_video_stardard(const struct tvp7000_video_std *std); static int tvp7000_setup_video_standard(const struct tvp7000_video_std *std);
static int tvp7000_device_init(struct vpfe_capture_params *params); static int tvp7000_device_init(struct vpfe_capture_params *params);
static int tvp7000_device_cmd(u32 cmd, void *arg); static int tvp7000_device_cmd(u32 cmd, void *arg);
...@@ -576,7 +576,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter, ...@@ -576,7 +576,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter,
FN_IN; FN_IN;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_WRITE_BYTE)) { I2C_FUNC_SMBUS_WRITE_BYTE))
{
DPRINTK("Functionality check failed for %s\n", DPRINTK("Functionality check failed for %s\n",
client_name); client_name);
return err; return err;
...@@ -584,7 +585,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter, ...@@ -584,7 +585,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter,
tvp7000_client = kmalloc(sizeof(struct i2c_client), tvp7000_client = kmalloc(sizeof(struct i2c_client),
GFP_KERNEL); GFP_KERNEL);
if (tvp7000_client == NULL) { if (tvp7000_client == NULL)
{
err = -ENOMEM; err = -ENOMEM;
DPRINTK("Couldn't allocate memory for %s\n", DPRINTK("Couldn't allocate memory for %s\n",
client_name); client_name);
...@@ -599,7 +601,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter, ...@@ -599,7 +601,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter,
strlcpy(tvp7000_client->name, client_name, I2C_NAME_SIZE); strlcpy(tvp7000_client->name, client_name, I2C_NAME_SIZE);
err = i2c_attach_client(tvp7000_client); err = i2c_attach_client(tvp7000_client);
if (err) { if (err)
{
DPRINTK("Couldn't attach %s\n", client_name); DPRINTK("Couldn't attach %s\n", client_name);
kfree(tvp7000_client); kfree(tvp7000_client);
return err; return err;
...@@ -622,7 +625,8 @@ static int tvp7000_detach_client(struct i2c_client *client) ...@@ -622,7 +625,8 @@ static int tvp7000_detach_client(struct i2c_client *client)
FN_IN; FN_IN;
err = i2c_detach_client(client); err = i2c_detach_client(client);
if (err) { if (err)
{
DPRINTK("Client deregistration failed, \ DPRINTK("Client deregistration failed, \
client not detached.\n"); client not detached.\n");
return err; return err;
...@@ -651,8 +655,7 @@ static void tvp7000_device_power_on(bool on) ...@@ -651,8 +655,7 @@ static void tvp7000_device_power_on(bool on)
udelay(5); udelay(5);
} }
static int tvp7000_setup_video_stardard( static int tvp7000_setup_video_standard(const struct tvp7000_video_std *std)
const struct tvp7000_video_std *std)
{ {
int err = 0; int err = 0;
int val; int val;
...@@ -660,17 +663,13 @@ static int tvp7000_setup_video_stardard( ...@@ -660,17 +663,13 @@ static int tvp7000_setup_video_stardard(
if (std == NULL) if (std == NULL)
return -EINVAL; return -EINVAL;
err |= tvp7000_write_reg(TVP7000_PLL_DIVIDE_MSB, err |= tvp7000_write_reg(TVP7000_PLL_DIVIDE_MSB, std->plldiv_msb);
std->plldiv_msb); err |= tvp7000_write_reg(TVP7000_PLL_DIVIDE_LSB, std->plldiv_lsb);
err |= tvp7000_write_reg(TVP7000_PLL_DIVIDE_LSB, err |= tvp7000_write_reg(TVP7000_PLL_CTRL, std->pll_ctrl);
std->plldiv_lsb);
err |= tvp7000_write_reg(TVP7000_PLL_CTRL,
std->pll_ctrl);
val = tvp7000_read_reg(TVP7000_PHASE_SELECT); val = tvp7000_read_reg(TVP7000_PHASE_SELECT);
val &= ~0x01; val &= ~0x01;
err |= tvp7000_write_reg(TVP7000_PHASE_SELECT, err |= tvp7000_write_reg(TVP7000_PHASE_SELECT, (std->phase_select_bit0 & 0x01) | val);
(std->phase_select_bit0 & 0x01) | val);
return err; return err;
} }
...@@ -678,7 +677,7 @@ static int tvp7000_setup_video_stardard( ...@@ -678,7 +677,7 @@ static int tvp7000_setup_video_stardard(
static int tvp7000_selmux(void) static int tvp7000_selmux(void)
{ {
if(tvp7000_write_reg(TVP7000_INPUT_MUX_1, 0)) // set channel 1 if (tvp7000_write_reg(TVP7000_INPUT_MUX_1, 0)) // set channel 1
return -1; return -1;
return 0; return 0;
} }
...@@ -687,7 +686,7 @@ static int input_signal_exist(void) ...@@ -687,7 +686,7 @@ static int input_signal_exist(void)
{ {
int val; int val;
val = tvp7000_read_reg(TVP7000_SYNC_DETECT_STATUS); val = tvp7000_read_reg(TVP7000_SYNC_DETECT_STATUS);
if((val & 0x80) && (val & 0x10)) if ((val & 0x80) && (val & 0x10))
{ {
return 0; return 0;
} }
...@@ -698,7 +697,8 @@ static int tvp7000_device_cmd(u32 cmd, void *arg) ...@@ -698,7 +697,8 @@ static int tvp7000_device_cmd(u32 cmd, void *arg)
{ {
int ret = 0; int ret = 0;
switch (cmd) { switch (cmd)
{
case 0: case 0:
case VIDIOC_INT_RESET: case VIDIOC_INT_RESET:
tvp7000_device_init(NULL); tvp7000_device_init(NULL);
...@@ -716,7 +716,7 @@ static int tvp7000_device_cmd(u32 cmd, void *arg) ...@@ -716,7 +716,7 @@ static int tvp7000_device_cmd(u32 cmd, void *arg)
int input = *(int *)arg; int input = *(int *)arg;
if (input == VPFE_AMUX_COMPONENT) if (input == VPFE_AMUX_COMPONENT)
{ {
if(tvp7000_device_init(NULL)) if (tvp7000_device_init(NULL))
ret = -EBUSY; ret = -EBUSY;
} }
else else
...@@ -730,7 +730,7 @@ static int tvp7000_device_cmd(u32 cmd, void *arg) ...@@ -730,7 +730,7 @@ static int tvp7000_device_cmd(u32 cmd, void *arg)
if (params->amuxmode == VPFE_AMUX_COMPONENT) if (params->amuxmode == VPFE_AMUX_COMPONENT)
{ {
ret = tvp7000_setup_video_stardard(STD(VIDEO480P60HZ)); ret = tvp7000_setup_video_standard(STD(VIDEO480P60HZ));
} }
else else
ret = -1; ret = -1;
...@@ -753,7 +753,7 @@ static int tvp7000_device_init(struct vpfe_capture_params *params) ...@@ -753,7 +753,7 @@ static int tvp7000_device_init(struct vpfe_capture_params *params)
/* initialize TVP7000 as its default values */ /* initialize TVP7000 as its default values */
tvp7000_write_inittab(tvp7000_init_default, NUM_OF_REGS(tvp7000_init_default)); tvp7000_write_inittab(tvp7000_init_default, NUM_OF_REGS(tvp7000_init_default));
tvp7000_write_inittab(tvp7000_init_component, NUM_OF_REGS(tvp7000_init_component)); tvp7000_write_inittab(tvp7000_init_component, NUM_OF_REGS(tvp7000_init_component));
if(tvp7000_selmux()) if (tvp7000_selmux())
return -1; return -1;
return 0; return 0;
} }
...@@ -804,14 +804,16 @@ static __init int tvp7000_init(void) ...@@ -804,14 +804,16 @@ static __init int tvp7000_init(void)
break; break;
} }
} }
if (err) { if (err)
{
DPRINTK("I2C driver %s add failed\n", DPRINTK("I2C driver %s add failed\n",
tvp7000_driver.driver.name); tvp7000_driver.driver.name);
return err; return err;
} }
err = vpfe_capture_device_register(&tvp7000_capture_device); err = vpfe_capture_device_register(&tvp7000_capture_device);
if (err) { if (err)
{
DPRINTK("VPFE Capture Device %s register failed\n", DPRINTK("VPFE Capture Device %s register failed\n",
tvp7000_capture_device.name); tvp7000_capture_device.name);
return err; return err;
......
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