Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci-2.6.23
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci-2.6.23
Commits
3560f6dc
Commit
3560f6dc
authored
Aug 01, 2008
by
吴智聪(John Wu)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up code and fix some typo in vpfe and tvp7000 code
parent
a5555708
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
759 additions
and
624 deletions
+759
-624
drivers/media/video/davinci_vpfe.c
drivers/media/video/davinci_vpfe.c
+666
-533
drivers/media/video/tvp7000.c
drivers/media/video/tvp7000.c
+93
-91
No files found.
drivers/media/video/davinci_vpfe.c
View file @
3560f6dc
This diff is collapsed.
Click to expand it.
drivers/media/video/tvp7000.c
View file @
3560f6dc
...
@@ -330,7 +330,7 @@ static const struct tvp7000_video_std video_std[] = {
...
@@ -330,7 +330,7 @@ static const struct tvp7000_video_std video_std[] = {
.
plldiv_lsb
=
0x00
,
.
plldiv_lsb
=
0x00
,
.
pll_ctrl
=
0x68
,
.
pll_ctrl
=
0x68
,
.
phase_select_bit0
=
0x01
,
.
phase_select_bit0
=
0x01
,
},
},
{
/* VGA standard: 640*480 resolution,72HZ refresh rate,
{
/* VGA standard: 640*480 resolution,72HZ refresh rate,
37.9kHZ Horizontal frequency,31.5MHZ pixel rate,
37.9kHZ Horizontal frequency,31.5MHZ pixel rate,
*/
*/
...
@@ -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_sta
r
dard
(
const
struct
tvp7000_video_std
*
std
);
static
int
tvp7000_setup_video_sta
n
dard
(
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
);
...
@@ -545,7 +545,7 @@ static inline int tvp7000_write_reg(u8 reg, u8 value)
...
@@ -545,7 +545,7 @@ static inline int tvp7000_write_reg(u8 reg, u8 value)
int
ret
;
int
ret
;
ret
=
i2c_smbus_write_byte_data
(
tvp7000_client
,
ret
=
i2c_smbus_write_byte_data
(
tvp7000_client
,
reg
,
value
);
reg
,
value
);
if
(
ret
!=
0
)
if
(
ret
!=
0
)
DPRINTK
(
"Write Error Address = %x
\n
"
,
reg
);
DPRINTK
(
"Write Error Address = %x
\n
"
,
reg
);
...
@@ -562,7 +562,7 @@ static int tvp7000_write_inittab(const struct i2c_reg_value *regs, int num)
...
@@ -562,7 +562,7 @@ static int tvp7000_write_inittab(const struct i2c_reg_value *regs, int num)
for
(
i
=
0
;
i
<
num
;
i
++
)
for
(
i
=
0
;
i
<
num
;
i
++
)
err
|=
tvp7000_write_reg
(
regs
[
i
].
reg
,
regs
[
i
].
value
);
err
|=
tvp7000_write_reg
(
regs
[
i
].
reg
,
regs
[
i
].
value
);
return
err
;
return
err
;
}
}
...
@@ -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
;
...
@@ -638,7 +642,7 @@ static void tvp7000_device_power_on(bool on)
...
@@ -638,7 +642,7 @@ static void tvp7000_device_power_on(bool on)
/* enable the GPIO(39) direction mode as output */
/* enable the GPIO(39) direction mode as output */
gpio_direction_output
(
HD_CAP_GPIO
,
level
);
gpio_direction_output
(
HD_CAP_GPIO
,
level
);
/* when on == true */
/* when on == true */
/* set the Reset pin level as High for 5ms */
/* set the Reset pin level as High for 5ms */
gpio_set_value
(
HD_CAP_GPIO
,
level
);
gpio_set_value
(
HD_CAP_GPIO
,
level
);
mdelay
(
5
);
mdelay
(
5
);
/* pull down the Reset pin level for 5us,
/* pull down the Reset pin level for 5us,
...
@@ -651,95 +655,91 @@ static void tvp7000_device_power_on(bool on)
...
@@ -651,95 +655,91 @@ 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
;
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
;
}
}
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
;
}
}
static
int
input_signal_exist
(
void
)
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
;
}
}
return
-
1
;
return
-
1
;
}
}
static
int
tvp7000_device_cmd
(
u32
cmd
,
void
*
arg
)
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
);
break
;
break
;
case
VIDIOC_G_INPUT
:
case
VIDIOC_G_INPUT
:
{
{
if
(
!
input_signal_exist
())
if
(
!
input_signal_exist
())
*
(
int
*
)
arg
=
VPFE_AMUX_COMPONENT
;
*
(
int
*
)
arg
=
VPFE_AMUX_COMPONENT
;
else
else
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
break
;
break
;
}
}
case
VIDIOC_S_INPUT
:
case
VIDIOC_S_INPUT
:
{
{
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
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
break
;
break
;
}
}
case
VPFE_CMD_CONFIG_CAPTURE
:
case
VPFE_CMD_CONFIG_CAPTURE
:
{
{
struct
vpfe_capture_params
*
params
=
struct
vpfe_capture_params
*
params
=
(
struct
vpfe_capture_params
*
)
arg
;
(
struct
vpfe_capture_params
*
)
arg
;
if
(
params
->
amuxmode
==
VPFE_AMUX_COMPONENT
)
if
(
params
->
amuxmode
==
VPFE_AMUX_COMPONENT
)
{
{
ret
=
tvp7000_setup_video_star
dard
(
STD
(
VIDEO480P60HZ
));
ret
=
tvp7000_setup_video_stan
dard
(
STD
(
VIDEO480P60HZ
));
}
}
else
else
ret
=
-
1
;
ret
=
-
1
;
break
;
break
;
}
}
default:
default:
break
;
break
;
}
}
return
ret
;
return
ret
;
}
}
static
int
tvp7000_device_init
(
struct
vpfe_capture_params
*
params
)
static
int
tvp7000_device_init
(
struct
vpfe_capture_params
*
params
)
...
@@ -753,20 +753,20 @@ static int tvp7000_device_init(struct vpfe_capture_params *params)
...
@@ -753,20 +753,20 @@ 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
;
}
}
static
int
tvp7000_device_active
(
void
)
static
int
tvp7000_device_active
(
void
)
{
{
tvp7000_device_power_on
(
true
);
tvp7000_device_power_on
(
true
);
return
0
;
return
0
;
}
}
static
int
tvp7000_device_deactive
(
void
)
static
int
tvp7000_device_deactive
(
void
)
{
{
tvp7000_device_power_on
(
false
);
tvp7000_device_power_on
(
false
);
return
0
;
return
0
;
}
}
...
@@ -776,11 +776,11 @@ static int tvp7000_device_cleanup(void)
...
@@ -776,11 +776,11 @@ static int tvp7000_device_cleanup(void)
return
0
;
return
0
;
}
}
static
struct
vpfe_capture_device
tvp7000_capture_device
=
{
static
struct
vpfe_capture_device
tvp7000_capture_device
=
{
.
name
=
"TVP7000"
,
.
name
=
"TVP7000"
,
.
id
=
VPFE_CAPTURE_ID_TVP7000
,
.
id
=
VPFE_CAPTURE_ID_TVP7000
,
.
capture_device_init
=
tvp7000_device_init
,
.
capture_device_init
=
tvp7000_device_init
,
.
capture_device_cmd
=
tvp7000_device_cmd
,
.
capture_device_cmd
=
tvp7000_device_cmd
,
.
capture_device_active
=
tvp7000_device_active
,
.
capture_device_active
=
tvp7000_device_active
,
.
capture_device_deactive
=
tvp7000_device_deactive
,
.
capture_device_deactive
=
tvp7000_device_deactive
,
.
capture_device_cleanup
=
tvp7000_device_cleanup
,
.
capture_device_cleanup
=
tvp7000_device_cleanup
,
...
@@ -788,30 +788,32 @@ static struct vpfe_capture_device tvp7000_capture_device = {
...
@@ -788,30 +788,32 @@ static struct vpfe_capture_device tvp7000_capture_device = {
static
__init
int
tvp7000_init
(
void
)
static
__init
int
tvp7000_init
(
void
)
{
{
int
i
;
int
i
;
int
err
=
0
;
int
err
=
0
;
FN_IN
;
FN_IN
;
/* power on the tvp7000 Video decoder*/
/* power on the tvp7000 Video decoder*/
tvp7000_device_power_on
(
true
);
tvp7000_device_power_on
(
true
);
mdelay
(
500
);
mdelay
(
500
);
for
(
i
=
0
;
i
<
TVP7000_I2C_RETRY
;
i
++
)
for
(
i
=
0
;
i
<
TVP7000_I2C_RETRY
;
i
++
)
{
{
err
=
i2c_add_driver
(
&
tvp7000_driver
);
err
=
i2c_add_driver
(
&
tvp7000_driver
);
if
(
!
err
)
if
(
!
err
)
{
{
break
;
break
;
}
}
}
}
if
(
err
)
{
if
(
err
)
DPRINTK
(
"I2C driver %s add failed
\n
"
,
{
tvp7000_driver
.
driver
.
name
);
DPRINTK
(
"I2C driver %s add failed
\n
"
,
return
err
;
tvp7000_driver
.
driver
.
name
);
}
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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment