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
Show 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
...
...
@@ -96,8 +96,8 @@ static struct v4l2_fract sp_aspect = VPFE_PIXELASPECT_NTSC_SP;
#define NTOSD_INPUTS 2
static
struct
v4l2_input
ntosd_inputs
[
NTOSD_INPUTS
]
=
{
{
0
,
"COMPOSITE"
,
V4L2_INPUT_TYPE_CAMERA
,
2
,
0
,
V4L2_STD_ALL
,
0
},
{
1
,
"COMPONENT"
,
V4L2_INPUT_TYPE_CAMERA
,
2
,
0
,
V4L2_STD_ALL
,
0
},
{
0
,
"COMPOSITE"
,
V4L2_INPUT_TYPE_CAMERA
,
2
,
0
,
V4L2_STD_ALL
,
0
},
{
1
,
"COMPONENT"
,
V4L2_INPUT_TYPE_CAMERA
,
2
,
0
,
V4L2_STD_ALL
,
0
},
};
static
vpfe_obj
vpfe_device
=
{
/* the default format is NTSC */
...
...
@@ -138,6 +138,7 @@ struct v4l2_capability vpfe_drvcap = {
.
capabilities
=
V4L2_CAP_VIDEO_CAPTURE
|
V4L2_CAP_STREAMING
};
static
irqreturn_t
vpfe_isr
(
int
irq
,
void
*
dev_id
)
{
vpfe_obj
*
vpfe
=
&
vpfe_device
;
...
...
@@ -149,42 +150,52 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id)
fid
=
ccdc_getfid
();
vpfe
->
field_id
^=
1
;
/* switch the software maintained field id */
debug_print
(
KERN_INFO
"field id = %x:%x.
\n
"
,
fid
,
vpfe
->
field_id
);
if
(
fid
==
vpfe
->
field_id
)
{
/* we are in-sync here, continue */
if
(
fid
==
0
)
{
if
(
fid
==
vpfe
->
field_id
)
{
/* we are in-sync here, continue */
if
(
fid
==
0
)
{
/* One frame is just being captured. If the next frame
is available, release the current frame and move on */
if
(
vpfe
->
curFrm
!=
vpfe
->
nextFrm
)
{
if
(
vpfe
->
curFrm
!=
vpfe
->
nextFrm
)
{
vpfe
->
curFrm
->
state
=
STATE_DONE
;
wake_up_interruptible
(
&
vpfe
->
curFrm
->
done
);
vpfe
->
curFrm
=
vpfe
->
nextFrm
;
}
/* based on whether the two fields are stored interleavely */
/* or separately in memory, reconfigure the CCDC memory address */
if
(
vpfe
->
field
==
V4L2_FIELD_SEQ_TB
)
{
if
(
vpfe
->
field
==
V4L2_FIELD_SEQ_TB
)
{
u32
addr
=
vpfe
->
curFrm
->
boff
+
vpfe
->
field_offset
;
ccdc_setfbaddr
((
unsigned
long
)
addr
);
}
}
else
if
(
fid
==
1
)
{
}
else
if
(
fid
==
1
)
{
/* if one field is just being captured */
/* configure the next frame */
/* get the next frame from the empty queue */
/* if no frame is available, hold on to the current buffer */
if
(
!
list_empty
(
&
vpfe
->
dma_queue
)
&&
vpfe
->
curFrm
==
vpfe
->
nextFrm
)
{
&&
vpfe
->
curFrm
==
vpfe
->
nextFrm
)
{
vpfe
->
nextFrm
=
list_entry
(
vpfe
->
dma_queue
.
next
,
struct
videobuf_buffer
,
queue
);
list_del
(
&
vpfe
->
nextFrm
->
queue
);
vpfe
->
nextFrm
->
state
=
STATE_ACTIVE
;
ccdc_setfbaddr
((
unsigned
long
)
vpfe
->
nextFrm
->
boff
);
}
if
(
vpfe
->
mode_changed
)
{
if
(
vpfe
->
mode_changed
)
{
ccdc_setwin
(
&
vpfe
->
ccdc_params
);
/* update the field offset */
vpfe
->
field_offset
=
(
vpfe
->
vwin
.
height
-
2
)
*
vpfe
->
vwin
.
width
;
vpfe
->
mode_changed
=
FALSE
;
}
}
}
else
if
(
fid
==
0
)
{
}
else
if
(
fid
==
0
)
{
/* recover from any hardware out-of-sync due to */
/* possible switch of video source */
/* for fid == 0, sync up the two fids */
...
...
@@ -217,7 +228,8 @@ static int buffer_prepare(struct videobuf_queue *q,
{
vpfe_obj
*
vpfe
=
&
vpfe_device
;
if
(
vb
->
state
==
STATE_NEEDS_INIT
)
{
if
(
vb
->
state
==
STATE_NEEDS_INIT
)
{
vb
->
width
=
vpfe
->
vwin
.
width
;
vb
->
height
=
vpfe
->
vwin
.
height
;
vb
->
size
=
VPFE_MAX_FBUF_SIZE
;
...
...
@@ -235,7 +247,8 @@ buffer_config(struct videobuf_queue *q, unsigned int count)
vpfe_obj
*
vpfe
=
&
vpfe_device
;
int
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
q
->
bufs
[
i
]
->
boff
=
virt_to_phys
(
vpfe
->
fbuffers
[
i
]);
debug_print
(
KERN_INFO
"buffer address: %x
\n
"
,
q
->
bufs
[
i
]
->
boff
);
}
...
...
@@ -248,13 +261,16 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
int
i
;
*
size
=
VPFE_MAX_FBUF_SIZE
;
for
(
i
=
VPFE_DEFNUM_FBUFS
;
i
<
*
count
;
i
++
)
{
for
(
i
=
VPFE_DEFNUM_FBUFS
;
i
<
*
count
;
i
++
)
{
u32
size
=
PAGE_SIZE
<<
VPFE_MAX_FBUF_ORDER
;
void
*
mem
=
(
void
*
)
__get_free_pages
(
GFP_KERNEL
|
GFP_DMA
,
VPFE_MAX_FBUF_ORDER
);
if
(
mem
)
{
if
(
mem
)
{
unsigned
long
adr
=
(
unsigned
long
)
mem
;
while
(
size
>
0
)
{
while
(
size
>
0
)
{
/* make sure the frame buffers are never
swapped out of memory */
SetPageReserved
(
virt_to_page
(
adr
));
...
...
@@ -262,7 +278,9 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
size
-=
PAGE_SIZE
;
}
vpfe
->
fbuffers
[
i
]
=
mem
;
}
else
{
}
else
{
break
;
}
}
...
...
@@ -283,9 +301,10 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static
void
buffer_release
(
struct
videobuf_queue
*
q
,
struct
videobuf_buffer
*
vb
)
{
/* free the buffer if it is not one of the 3 allocated at initializaiton time */
if
(
vb
->
i
<
vpfe_device
.
numbuffers
if
(
vb
->
i
<
vpfe_device
.
numbuffers
&&
vb
->
i
>=
VPFE_DEFNUM_FBUFS
&&
vpfe_device
.
fbuffers
[
vb
->
i
]){
&&
vpfe_device
.
fbuffers
[
vb
->
i
])
{
free_pages
((
unsigned
long
)
vpfe_device
.
fbuffers
[
vb
->
i
],
VPFE_MAX_FBUF_ORDER
);
vpfe_device
.
fbuffers
[
vb
->
i
]
=
NULL
;
...
...
@@ -330,7 +349,8 @@ static int vpfe_select_capture_device(int id)
down_interruptible
(
&
vpfe_device
.
device_list_lock
);
list_for_each_entry
(
device
,
&
vpfe_device
.
capture_device_list
,
device_list
){
if
(
device
->
id
==
id
)
{
if
(
device
->
id
==
id
)
{
err
=
vpfe_capture_device_active
(
device
);
up
(
&
vpfe_device
.
device_list_lock
);
return
err
;
...
...
@@ -348,18 +368,21 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
vpfe_fh
*
fh
=
file
->
private_data
;
int
ret
=
0
;
switch
(
cmd
)
{
switch
(
cmd
)
{
case
VIDIOC_S_CTRL
:
case
VIDIOC_S_CROP
:
case
VIDIOC_S_FMT
:
case
VIDIOC_S_STD
:
ret
=
v4l2_prio_check
(
&
vpfe
->
prio
,
&
fh
->
prio
);
if
(
0
!=
ret
)
{
if
(
0
!=
ret
)
{
return
ret
;
}
break
;
}
switch
(
cmd
)
{
switch
(
cmd
)
{
case
VIDIOC_QUERYCAP
:
{
struct
v4l2_capability
*
cap
=
(
struct
v4l2_capability
*
)
arg
;
...
...
@@ -373,16 +396,21 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
u32
index
=
fmt
->
index
;
memset
(
fmt
,
0
,
sizeof
(
*
fmt
));
fmt
->
index
=
index
;
if
(
index
==
0
)
{
if
(
index
==
0
)
{
/* only yuv4:2:2 format is supported at this point */
fmt
->
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
strcpy
(
fmt
->
description
,
"YCbCr4:2:2 Interleaved UYUV"
);
fmt
->
pixelformat
=
V4L2_PIX_FMT_UYVY
;
}
else
if
(
index
==
1
)
{
}
else
if
(
index
==
1
)
{
fmt
->
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
strcpy
(
fmt
->
description
,
"YCbCr4:2:2 Interleaved YUYV"
);
fmt
->
pixelformat
=
V4L2_PIX_FMT_YUYV
;
}
else
{
}
else
{
ret
=
-
EINVAL
;
}
break
;
...
...
@@ -390,9 +418,12 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
case
VIDIOC_G_FMT
:
{
struct
v4l2_format
*
fmt
=
(
struct
v4l2_format
*
)
arg
;
if
(
fmt
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
if
(
fmt
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
ret
=
-
EINVAL
;
}
else
{
}
else
{
struct
v4l2_pix_format
*
pixfmt
=
&
fmt
->
fmt
.
pix
;
down_interruptible
(
&
vpfe
->
lock
);
pixfmt
->
width
=
vpfe
->
vwin
.
width
;
...
...
@@ -411,50 +442,65 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
struct
v4l2_format
*
fmt
=
(
struct
v4l2_format
*
)
arg
;
struct
v4l2_pix_format
*
pixfmt
=
&
fmt
->
fmt
.
pix
;
ccdc_params_ycbcr
*
params
=
&
vpfe
->
ccdc_params
;
if
(
vpfe
->
started
)
{
/* make sure streaming is not started */
if
(
vpfe
->
started
)
{
/* make sure streaming is not started */
ret
=
-
EBUSY
;
break
;
}
down_interruptible
(
&
vpfe
->
lock
);
if
(
fmt
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
if
(
fmt
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
ret
=
-
EINVAL
;
up
(
&
vpfe
->
lock
);
break
;
}
if
((
pixfmt
->
width
+
vpfe
->
vwin
.
left
<=
vpfe
->
bounds
.
width
)
&
(
pixfmt
->
height
+
vpfe
->
vwin
.
top
<=
vpfe
->
bounds
.
height
))
{
(
pixfmt
->
height
+
vpfe
->
vwin
.
top
<=
vpfe
->
bounds
.
height
))
{
/* this is the case when no scaling is supported */
/* crop window is directed modified */
vpfe
->
vwin
.
height
=
pixfmt
->
height
;
vpfe
->
vwin
.
width
=
pixfmt
->
width
;
params
->
win
.
width
=
pixfmt
->
width
;
params
->
win
.
height
=
pixfmt
->
height
;
}
else
{
}
else
{
ret
=
-
EINVAL
;
up
(
&
vpfe
->
lock
);
break
;
}
/* setup the CCDC parameters accordingly */
if
(
pixfmt
->
pixelformat
==
V4L2_PIX_FMT_YUYV
)
{
if
(
pixfmt
->
pixelformat
==
V4L2_PIX_FMT_YUYV
)
{
params
->
pix_order
=
CCDC_PIXORDER_YCBYCR
;
vpfe
->
pixelfmt
=
pixfmt
->
pixelformat
;
}
else
if
(
pixfmt
->
pixelformat
==
V4L2_PIX_FMT_UYVY
)
{
}
else
if
(
pixfmt
->
pixelformat
==
V4L2_PIX_FMT_UYVY
)
{
params
->
pix_order
=
CCDC_PIXORDER_CBYCRY
;
vpfe
->
pixelfmt
=
pixfmt
->
pixelformat
;
}
else
{
}
else
{
ret
=
-
EINVAL
;
/* not supported format */
up
(
&
vpfe
->
lock
);
break
;
}
if
(
pixfmt
->
field
==
V4L2_FIELD_NONE
||
pixfmt
->
field
==
V4L2_FIELD_INTERLACED
)
{
pixfmt
->
field
==
V4L2_FIELD_INTERLACED
)
{
params
->
buf_type
=
CCDC_BUFTYPE_FLD_INTERLEAVED
;
vpfe
->
field
=
pixfmt
->
field
;
}
else
if
(
pixfmt
->
field
==
V4L2_FIELD_SEQ_TB
)
{
}
else
if
(
pixfmt
->
field
==
V4L2_FIELD_SEQ_TB
)
{
params
->
buf_type
=
CCDC_BUFTYPE_FLD_SEPARATED
;
vpfe
->
field
=
pixfmt
->
field
;
}
else
{
}
else
{
ret
=
-
EINVAL
;
}
...
...
@@ -466,14 +512,18 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
case
VIDIOC_TRY_FMT
:
{
struct
v4l2_format
*
fmt
=
(
struct
v4l2_format
*
)
arg
;
if
(
fmt
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
if
(
fmt
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
ret
=
-
EINVAL
;
}
else
{
}
else
{
struct
v4l2_pix_format
*
pixfmt
=
&
fmt
->
fmt
.
pix
;
if
(
pixfmt
->
width
>
vpfe
->
bounds
.
width
||
pixfmt
->
height
>
vpfe
->
bounds
.
height
||
(
pixfmt
->
pixelformat
!=
V4L2_PIX_FMT_UYVY
&&
pixfmt
->
pixelformat
!=
V4L2_PIX_FMT_YUYV
))
{
pixfmt
->
pixelformat
!=
V4L2_PIX_FMT_YUYV
))
{
ret
=
-
EINVAL
;
}
}
...
...
@@ -490,26 +540,32 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
v4l2_std_id
id
=
*
(
v4l2_std_id
*
)
arg
;
int
sqp
=
0
;
if
(
vpfe
->
started
)
{
/* make sure streaming is not started */
if
(
vpfe
->
started
)
{
/* make sure streaming is not started */
ret
=
-
EBUSY
;
break
;
}
down_interruptible
(
&
vpfe
->
lock
);
if
(
id
&
V4L2_STD_625_50
)
{
if
(
id
&
V4L2_STD_625_50
)
{
vpfe
->
std
=
id
;
vpfe
->
bounds
=
vpfe
->
vwin
=
pal_bounds
;
vpfe
->
pixelaspect
=
pal_aspect
;
vpfe
->
ccdc_params
.
win
=
pal_bounds
;
vpfe
->
ccdc_params
.
frm_fmt
=
CCDC_FRMFMT_INTERLACED
;
vpfe
->
ccdc_params
.
pix_fmt
=
CCDC_PIXFMT_YCBCR_8BIT
;
}
else
if
(
id
&
V4L2_STD_525_60
)
{
}
else
if
(
id
&
V4L2_STD_525_60
)
{
vpfe
->
std
=
id
;
vpfe
->
bounds
=
vpfe
->
vwin
=
ntsc_bounds
;
vpfe
->
pixelaspect
=
ntsc_aspect
;
vpfe
->
ccdc_params
.
win
=
ntsc_bounds
;
vpfe
->
ccdc_params
.
frm_fmt
=
CCDC_FRMFMT_INTERLACED
;
vpfe
->
ccdc_params
.
pix_fmt
=
CCDC_PIXFMT_YCBCR_8BIT
;
}
else
if
(
id
&
VPFE_STD_625_50_SQP
)
{
}
else
if
(
id
&
VPFE_STD_625_50_SQP
)
{
vpfe
->
std
=
id
;
vpfe
->
bounds
=
vpfe
->
vwin
=
palsp_bounds
;
vpfe
->
pixelaspect
=
sp_aspect
;
...
...
@@ -517,7 +573,9 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
vpfe
->
ccdc_params
.
pix_fmt
=
CCDC_PIXFMT_YCBCR_8BIT
;
sqp
=
1
;
id
>>=
32
;
}
else
if
(
id
&
VPFE_STD_525_60_SQP
)
{
}
else
if
(
id
&
VPFE_STD_525_60_SQP
)
{
vpfe
->
std
=
id
;
sqp
=
1
;
vpfe
->
std
=
id
;
...
...
@@ -527,28 +585,36 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
vpfe
->
ccdc_params
.
win
=
ntscsp_bounds
;
vpfe
->
ccdc_params
.
frm_fmt
=
CCDC_FRMFMT_INTERLACED
;
vpfe
->
ccdc_params
.
pix_fmt
=
CCDC_PIXFMT_YCBCR_8BIT
;
}
else
if
(
id
&
VPFE_STD_AUTO
)
{
}
else
if
(
id
&
VPFE_STD_AUTO
)
{
vpfe
->
bounds
=
vpfe
->
vwin
=
pal_bounds
;
vpfe
->
pixelaspect
=
pal_aspect
;
vpfe
->
ccdc_params
.
win
=
pal_bounds
;
vpfe
->
ccdc_params
.
frm_fmt
=
CCDC_FRMFMT_INTERLACED
;
vpfe
->
ccdc_params
.
pix_fmt
=
CCDC_PIXFMT_YCBCR_8BIT
;
vpfe
->
std
=
id
;
}
else
if
(
id
&
VPFE_STD_AUTO_SQP
)
{
}
else
if
(
id
&
VPFE_STD_AUTO_SQP
)
{
vpfe
->
std
=
id
;
vpfe
->
bounds
=
vpfe
->
vwin
=
palsp_bounds
;
vpfe
->
pixelaspect
=
sp_aspect
;
vpfe
->
ccdc_params
.
frm_fmt
=
CCDC_FRMFMT_INTERLACED
;
vpfe
->
ccdc_params
.
pix_fmt
=
CCDC_PIXFMT_YCBCR_8BIT
;
sqp
=
1
;
}
else
if
(
id
&
V4L2_STD_HD_480P
)
{
}
else
if
(
id
&
V4L2_STD_HD_480P
)
{
vpfe
->
std
=
id
;
vpfe
->
bounds
=
vpfe
->
vwin
=
hd_480p_bounds
;
vpfe
->
pixelaspect
=
sp_aspect
;
vpfe
->
ccdc_params
.
win
=
hd_480p_bounds
;
vpfe
->
ccdc_params
.
frm_fmt
=
CCDC_FRMFMT_PROGRESSIVE
;
vpfe
->
ccdc_params
.
pix_fmt
=
CCDC_PIXFMT_YCBCR_16BIT
;
}
else
{
}
else
{
ret
=
-
EINVAL
;
}
...
...
@@ -566,46 +632,59 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
u32
index
=
std
->
index
;
memset
(
std
,
0
,
sizeof
(
*
std
));
std
->
index
=
index
;
if
(
index
==
0
)
{
if
(
index
==
0
)
{
std
->
id
=
V4L2_STD_525_60
;
strcpy
(
std
->
name
,
"SD-525line-30fps"
);
std
->
framelines
=
525
;
std
->
frameperiod
.
numerator
=
1001
;
std
->
frameperiod
.
denominator
=
30000
;
}
else
if
(
index
==
1
)
{
}
else
if
(
index
==
1
)
{
std
->
id
=
V4L2_STD_625_50
;
strcpy
(
std
->
name
,
"SD-625line-25fps"
);
std
->
framelines
=
625
;
std
->
frameperiod
.
numerator
=
1
;
std
->
frameperiod
.
denominator
=
25
;
}
else
if
(
index
==
2
)
{
}
else
if
(
index
==
2
)
{
std
->
id
=
VPFE_STD_625_50_SQP
;
strcpy
(
std
->
name
,
"SD-625line-25fps square pixel"
);
std
->
framelines
=
625
;
std
->
frameperiod
.
numerator
=
1
;
std
->
frameperiod
.
denominator
=
25
;
}
else
if
(
index
==
3
)
{
}
else
if
(
index
==
3
)
{
std
->
id
=
VPFE_STD_525_60_SQP
;
strcpy
(
std
->
name
,
"SD-525line-25fps square pixel"
);
std
->
framelines
=
525
;
std
->
frameperiod
.
numerator
=
1001
;
std
->
frameperiod
.
denominator
=
30000
;
}
else
if
(
index
==
4
)
{
}
else
if
(
index
==
4
)
{
std
->
id
=
VPFE_STD_AUTO
;
strcpy
(
std
->
name
,
"automatic detect"
);
std
->
framelines
=
625
;
std
->
frameperiod
.
numerator
=
1
;
std
->
frameperiod
.
denominator
=
1
;
}
else
if
(
index
==
5
)
{
}
else
if
(
index
==
5
)
{
std
->
id
=
VPFE_STD_AUTO_SQP
;
strcpy
(
std
->
name
,
"automatic detect square pixel"
);
std
->
framelines
=
625
;
std
->
frameperiod
.
numerator
=
1
;
std
->
frameperiod
.
denominator
=
1
;
}
else
{
}
else
{
ret
=
-
EINVAL
;
}
break
;
...
...
@@ -614,7 +693,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
{
struct
v4l2_input
*
input
=
(
struct
v4l2_input
*
)
arg
;
if
(
input
->
index
<
0
||
input
->
index
>=
NTOSD_INPUTS
)
if
(
input
->
index
<
0
||
input
->
index
>=
NTOSD_INPUTS
)
ret
=
-
EINVAL
;
memcpy
(
input
,
&
ntosd_inputs
[
input
->
index
],
sizeof
(
struct
v4l2_input
));
...
...
@@ -656,17 +735,23 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
case
VIDIOC_G_PARM
:
{
struct
v4l2_streamparm
*
parm
=
(
struct
v4l2_streamparm
*
)
arg
;
if
(
parm
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
if
(
parm
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
/* only capture is supported */
ret
=
-
EINVAL
;
}
else
{
}
else
{
struct
v4l2_captureparm
*
capparm
=
&
parm
->
parm
.
capture
;
memset
(
capparm
,
0
,
sizeof
(
struct
v4l2_captureparm
));
down_interruptible
(
&
vpfe
->
lock
);
if
(
vpfe
->
std
&
V4L2_STD_625_50
)
{
if
(
vpfe
->
std
&
V4L2_STD_625_50
)
{
capparm
->
timeperframe
.
numerator
=
1
;
capparm
->
timeperframe
.
denominator
=
25
;
/* PAL 25fps */
}
else
{
}
else
{
capparm
->
timeperframe
.
numerator
=
1001
;
capparm
->
timeperframe
.
denominator
=
30000
;
/*NTSC 29.97fps */
}
...
...
@@ -699,9 +784,12 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
case
VIDIOC_G_CROP
:
{
struct
v4l2_crop
*
crop
=
arg
;
if
(
crop
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
if
(
crop
->
type
!=
V4L2_BUF_TYPE_VIDEO_CAPTURE
)
{
ret
=
-
EINVAL
;
}
else
{
}
else
{
crop
->
c
=
vpfe
->
vwin
;
}
break
;
...
...
@@ -710,7 +798,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
{
struct
v4l2_crop
*
crop
=
arg
;
ccdc_params_ycbcr
*
params
=
&
vpfe
->
ccdc_params
;
if
(
vpfe
->
started
)
{
/* make sure streaming is not started */
if
(
vpfe
->
started
)
{
/* make sure streaming is not started */
ret
=
-
EBUSY
;
break
;
}
...
...
@@ -720,13 +809,16 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
/* make sure parameters are valid */
if
(
crop
->
type
==
V4L2_BUF_TYPE_VIDEO_CAPTURE
&&
(
crop
->
c
.
left
+
crop
->
c
.
width
<=
vpfe
->
bounds
.
left
+
vpfe
->
bounds
.
width
)
&&
(
crop
->
c
.
top
+
crop
->
c
.
height
<=
vpfe
->
bounds
.
top
+
vpfe
->
bounds
.
height
))
{
(
crop
->
c
.
top
+
crop
->
c
.
height
<=
vpfe
->
bounds
.
top
+
vpfe
->
bounds
.
height
))
{
down_interruptible
(
&
vpfe
->
lock
);
vpfe
->
vwin
=
crop
->
c
;
params
->
win
=
vpfe
->
vwin
;
up
(
&
vpfe
->
lock
);
}
else
{
}
else
{
ret
=
-
EINVAL
;
}
break
;
...
...
@@ -755,7 +847,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
}
case
VIDIOC_REQBUFS
:
if
(
vpfe
->
io_usrs
!=
0
)
{
if
(
vpfe
->
io_usrs
!=
0
)
{
ret
=
-
EBUSY
;
break
;
}
...
...
@@ -788,11 +881,13 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
ret
=
videobuf_dqbuf
(
&
vpfe
->
bufqueue
,
arg
,
0
);
break
;
case
VIDIOC_STREAMON
:
if
(
!
fh
->
io_allowed
)
{
if
(
!
fh
->
io_allowed
)
{
ret
=
-
EACCES
;
break
;
}
if
(
vpfe
->
started
){
if
(
vpfe
->
started
)
{
ret
=
-
EBUSY
;
break
;
}
...
...
@@ -803,7 +898,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
/* get the current and next frame buffers */
/* we expect at least one buffer is in driver at this point */
/* if not, error is returned */
if
(
list_empty
(
&
vpfe
->
dma_queue
))
{
if
(
list_empty
(
&
vpfe
->
dma_queue
))
{
ret
=
-
EIO
;
break
;
}
...
...
@@ -835,11 +931,13 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
break
;
case
VIDIOC_STREAMOFF
:
{
if
(
!
fh
->
io_allowed
)
{
if
(
!
fh
->
io_allowed
)
{
ret
=
-
EACCES
;
break
;
}
if
(
!
vpfe
->
started
){
if
(
!
vpfe
->
started
)
{
ret
=
-
EINVAL
;
break
;
}
...
...
@@ -855,7 +953,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
{
/* this can be used directly and bypass the V4L2 APIs */
ccdc_params_ycbcr
*
params
=
&
vpfe
->
ccdc_params
;
if
(
vpfe
->
started
){
if
(
vpfe
->
started
)
{
/* only allowed if streaming is not started */
ret
=
-
EBUSY
;
break
;
...
...
@@ -865,14 +964,20 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
have consistant settings */
*
params
=
(
*
(
ccdc_params_ycbcr
*
)
arg
);
vpfe
->
vwin
=
params
->
win
;
if
(
params
->
buf_type
==
CCDC_BUFTYPE_FLD_INTERLEAVED
)
{
if
(
params
->
buf_type
==
CCDC_BUFTYPE_FLD_INTERLEAVED
)
{
vpfe
->
field
=
V4L2_FIELD_INTERLACED
;
}
else
if
(
params
->
buf_type
==
CCDC_BUFTYPE_FLD_SEPARATED
)
{
}
else
if
(
params
->
buf_type
==
CCDC_BUFTYPE_FLD_SEPARATED
)
{
vpfe
->
field
=
V4L2_FIELD_SEQ_TB
;
}
if
(
params
->
pix_order
==
CCDC_PIXORDER_YCBYCR
)
{
if
(
params
->
pix_order
==
CCDC_PIXORDER_YCBYCR
)
{
vpfe
->
pixelfmt
=
V4L2_PIX_FMT_YUYV
;
}
else
if
(
params
->
pix_order
==
CCDC_PIXORDER_CBYCRY
)
{
}
else
if
(
params
->
pix_order
==
CCDC_PIXORDER_CBYCRY
)
{
vpfe
->
pixelfmt
=
V4L2_PIX_FMT_UYVY
;
}
up
(
&
vpfe
->
lock
);
...
...
@@ -885,7 +990,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
driver does not check the consistancy */
struct
vpfe_capture_params
*
params
=
(
struct
vpfe_capture_param
*
)
arg
;
v4l2_std_id
std
=
0
;
if
(
vpfe
->
started
){
if
(
vpfe
->
started
)
{
/* only allowed if streaming is not started */
ret
=
-
EBUSY
;
break
;
...
...
@@ -893,20 +999,28 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
down_interruptible
(
&
vpfe
->
lock
);
std
=
params
->
mode
;
if
(
params
->
squarepixel
)
{
/* square pixel mode */
if
(
params
->
squarepixel
)
{
/* square pixel mode */
std
<<=
32
;
}
if
(
std
&
V4L2_STD_625_50
)
{
if
(
std
&
V4L2_STD_625_50
)
{
vpfe
->
bounds
=
pal_bounds
;
vpfe
->
pixelaspect
=
pal_aspect
;
}
else
if
(
std
&
V4L2_STD_525_60
)
{
}
else
if
(
std
&
V4L2_STD_525_60
)
{
vpfe
->
bounds
=
ntsc_bounds
;
vpfe
->
pixelaspect
=
ntsc_aspect
;
}
else
if
(
std
&
VPFE_STD_625_50_SQP
)
{
}
else
if
(
std
&
VPFE_STD_625_50_SQP
)
{
vpfe
->
bounds
=
palsp_bounds
;
vpfe
->
pixelaspect
=
sp_aspect
;
}
else
if
(
std
&
VPFE_STD_525_60_SQP
)
{
}
else
if
(
std
&
VPFE_STD_525_60_SQP
)
{
vpfe
->
bounds
=
ntscsp_bounds
;
vpfe
->
pixelaspect
=
sp_aspect
;
}
...
...
@@ -928,7 +1042,8 @@ static int vpfe_ioctl(struct inode *inode, struct file *file,
{
int
ret
;
ret
=
video_usercopy
(
inode
,
file
,
cmd
,
arg
,
vpfe_doioctl
);
if
(
cmd
==
VIDIOC_S_FMT
||
cmd
==
VIDIOC_TRY_FMT
){
if
(
cmd
==
VIDIOC_S_FMT
||
cmd
==
VIDIOC_TRY_FMT
)
{
ret
=
video_usercopy
(
inode
,
file
,
VIDIOC_G_FMT
,
arg
,
vpfe_doioctl
);
}
...
...
@@ -949,14 +1064,18 @@ static int vpfe_open(struct inode *inode, struct file *filep)
debug_print
(
KERN_INFO
"vpfe: open minor=%d
\n
"
,
minor
);
/* check to make sure the minor numbers match */
if
(
vpfe_device
.
video_dev
&&
vpfe_device
.
video_dev
->
minor
==
minor
)
{
if
(
vpfe_device
.
video_dev
&&
vpfe_device
.
video_dev
->
minor
==
minor
)
{
vpfe
=
&
vpfe_device
;
}
else
{
/* device not found here */
}
else
{
/* device not found here */
return
-
ENODEV
;
}
/* allocate per filehandle data */
if
((
fh
=
kmalloc
(
sizeof
(
*
fh
),
GFP_KERNEL
))
==
NULL
)
{
if
((
fh
=
kmalloc
(
sizeof
(
*
fh
),
GFP_KERNEL
))
==
NULL
)
{
return
-
ENOMEM
;
}
filep
->
private_data
=
fh
;
...
...
@@ -979,7 +1098,8 @@ static int vpfe_release(struct inode *inode, struct file *filep)
vpfe_obj
*
vpfe
=
fh
->
dev
;
down_interruptible
(
&
vpfe
->
lock
);
if
(
fh
->
io_allowed
)
{
if
(
fh
->
io_allowed
)
{
vpfe
->
io_usrs
=
0
;
ccdc_enable
(
FALSE
);
vpfe
->
started
=
FALSE
;
...
...
@@ -1022,7 +1142,8 @@ static int __init vpfe_probe(struct device *device)
vpfe_obj
*
vpfe
=
&
vpfe_device
;
/* alloc video device */
if
((
vfd
=
video_device_alloc
())
==
NULL
)
{
if
((
vfd
=
video_device_alloc
())
==
NULL
)
{
return
-
ENOMEM
;
}
*
vfd
=
vpfe_video_template
;
...
...
@@ -1048,7 +1169,8 @@ static int __init vpfe_probe(struct device *device)
debug_print
(
KERN_INFO
"trying to register vpfe device.
\n
"
);
debug_print
(
KERN_INFO
"vpfe=%x,vpfe->video_dev=%x
\n
"
,
(
int
)
vpfe
,
(
int
)
&
vpfe
->
video_dev
);
if
(
video_register_device
(
vpfe
->
video_dev
,
VFL_TYPE_GRABBER
,
-
1
)
<
0
)
{
if
(
video_register_device
(
vpfe
->
video_dev
,
VFL_TYPE_GRABBER
,
-
1
)
<
0
)
{
video_device_release
(
vpfe
->
video_dev
);
vpfe
->
video_dev
=
NULL
;
return
-
1
;
...
...
@@ -1100,7 +1222,8 @@ int vpfe_capture_device_unregister(struct vpfe_capture_device *device)
down_interruptible
(
&
vpfe_device
.
lock
);
/* if the device to be unregistered is active,
deactivate it! */
if
(
IS_ACTIVE
(
device
))
{
if
(
IS_ACTIVE
(
device
))
{
DEVICE_DEACTIVATE
(
device
);
SET_ACTIVE_DEVICE
(
NULL
);
}
...
...
@@ -1170,12 +1293,15 @@ static int vpfe_init(void)
int
result
=
0
;
void
*
mem
;
/* allocate memory at initialization time to guarentee availability */
for
(
i
=
0
;
i
<
VPFE_DEFNUM_FBUFS
;
i
++
)
{
for
(
i
=
0
;
i
<
VPFE_DEFNUM_FBUFS
;
i
++
)
{
mem
=
(
void
*
)
__get_free_pages
(
GFP_KERNEL
|
GFP_DMA
,
VPFE_MAX_FBUF_ORDER
);
if
(
mem
)
{
if
(
mem
)
{
unsigned
long
adr
=
(
unsigned
long
)
mem
;
u32
size
=
PAGE_SIZE
<<
VPFE_MAX_FBUF_ORDER
;
while
(
size
>
0
)
{
while
(
size
>
0
)
{
/* make sure the frame buffers
are never swapped out of memory */
SetPageReserved
(
virt_to_page
(
adr
));
...
...
@@ -1184,8 +1310,11 @@ static int vpfe_init(void)
}
vpfe_device
.
fbuffers
[
i
]
=
(
u8
*
)
mem
;
debug_print
(
KERN_INFO
"memory address %d
\t
%x
\n
"
,
i
,
mem
);
}
else
{
while
(
--
i
>=
0
)
{
}
else
{
while
(
--
i
>=
0
)
{
free_pages
((
unsigned
long
)
vpfe_device
.
fbuffers
[
i
],
VPFE_MAX_FBUF_ORDER
);
}
...
...
@@ -1193,11 +1322,13 @@ static int vpfe_init(void)
return
-
ENOMEM
;
}
}
if
(
driver_register
(
&
vpfe_driver
)
!=
0
)
{
if
(
driver_register
(
&
vpfe_driver
)
!=
0
)
{
debug_print
(
KERN_INFO
"driver registration failed
\n
"
);
return
-
1
;
}
if
(
platform_device_register
(
&
_vpfe_device
)
!=
0
)
{
if
(
platform_device_register
(
&
_vpfe_device
)
!=
0
)
{
driver_unregister
(
&
vpfe_driver
);
debug_print
(
KERN_INFO
"device registration failed
\n
"
);
return
-
1
;
...
...
@@ -1207,7 +1338,8 @@ static int vpfe_init(void)
/* setup interrupt handling */
result
=
request_irq
(
IRQ_VDINT0
,
vpfe_isr
,
IRQF_DISABLED
,
"dm644xv4l2"
,
(
void
*
)
&
vpfe_device
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
printk
(
KERN_ERR
"DaVinci v4l2 capture driver: cannot initialize IRQ
\n
"
);
return
result
;
}
...
...
@@ -1227,7 +1359,8 @@ static void vpfe_cleanup(void)
/* disable interrupt */
free_irq
(
IRQ_VDINT0
,
&
vpfe_device
);
while
(
--
i
>=
0
)
{
while
(
--
i
>=
0
)
{
free_pages
((
unsigned
long
)
vpfe_device
.
fbuffers
[
i
],
VPFE_MAX_FBUF_ORDER
);
}
...
...
drivers/media/video/tvp7000.c
View file @
3560f6dc
...
...
@@ -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_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_cmd
(
u32
cmd
,
void
*
arg
);
...
...
@@ -576,7 +576,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter,
FN_IN
;
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
"
,
client_name
);
return
err
;
...
...
@@ -584,7 +585,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter,
tvp7000_client
=
kmalloc
(
sizeof
(
struct
i2c_client
),
GFP_KERNEL
);
if
(
tvp7000_client
==
NULL
)
{
if
(
tvp7000_client
==
NULL
)
{
err
=
-
ENOMEM
;
DPRINTK
(
"Couldn't allocate memory for %s
\n
"
,
client_name
);
...
...
@@ -599,7 +601,8 @@ static int tvp7000_detect_client(struct i2c_adapter *adapter,
strlcpy
(
tvp7000_client
->
name
,
client_name
,
I2C_NAME_SIZE
);
err
=
i2c_attach_client
(
tvp7000_client
);
if
(
err
)
{
if
(
err
)
{
DPRINTK
(
"Couldn't attach %s
\n
"
,
client_name
);
kfree
(
tvp7000_client
);
return
err
;
...
...
@@ -622,7 +625,8 @@ static int tvp7000_detach_client(struct i2c_client *client)
FN_IN
;
err
=
i2c_detach_client
(
client
);
if
(
err
)
{
if
(
err
)
{
DPRINTK
(
"Client deregistration failed, \
client not detached.
\n
"
);
return
err
;
...
...
@@ -651,8 +655,7 @@ static void tvp7000_device_power_on(bool on)
udelay
(
5
);
}
static
int
tvp7000_setup_video_stardard
(
const
struct
tvp7000_video_std
*
std
)
static
int
tvp7000_setup_video_standard
(
const
struct
tvp7000_video_std
*
std
)
{
int
err
=
0
;
int
val
;
...
...
@@ -660,17 +663,13 @@ static int tvp7000_setup_video_stardard(
if
(
std
==
NULL
)
return
-
EINVAL
;
err
|=
tvp7000_write_reg
(
TVP7000_PLL_DIVIDE_MSB
,
std
->
plldiv_msb
);
err
|=
tvp7000_write_reg
(
TVP7000_PLL_DIVIDE_LSB
,
std
->
plldiv_lsb
);
err
|=
tvp7000_write_reg
(
TVP7000_PLL_CTRL
,
std
->
pll_ctrl
);
err
|=
tvp7000_write_reg
(
TVP7000_PLL_DIVIDE_MSB
,
std
->
plldiv_msb
);
err
|=
tvp7000_write_reg
(
TVP7000_PLL_DIVIDE_LSB
,
std
->
plldiv_lsb
);
err
|=
tvp7000_write_reg
(
TVP7000_PLL_CTRL
,
std
->
pll_ctrl
);
val
=
tvp7000_read_reg
(
TVP7000_PHASE_SELECT
);
val
&=
~
0x01
;
err
|=
tvp7000_write_reg
(
TVP7000_PHASE_SELECT
,
(
std
->
phase_select_bit0
&
0x01
)
|
val
);
err
|=
tvp7000_write_reg
(
TVP7000_PHASE_SELECT
,
(
std
->
phase_select_bit0
&
0x01
)
|
val
);
return
err
;
}
...
...
@@ -678,7 +677,7 @@ static int tvp7000_setup_video_stardard(
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
0
;
}
...
...
@@ -687,7 +686,7 @@ static int input_signal_exist(void)
{
int
val
;
val
=
tvp7000_read_reg
(
TVP7000_SYNC_DETECT_STATUS
);
if
((
val
&
0x80
)
&&
(
val
&
0x10
))
if
((
val
&
0x80
)
&&
(
val
&
0x10
))
{
return
0
;
}
...
...
@@ -698,7 +697,8 @@ static int tvp7000_device_cmd(u32 cmd, void *arg)
{
int
ret
=
0
;
switch
(
cmd
)
{
switch
(
cmd
)
{
case
0
:
case
VIDIOC_INT_RESET
:
tvp7000_device_init
(
NULL
);
...
...
@@ -716,7 +716,7 @@ static int tvp7000_device_cmd(u32 cmd, void *arg)
int
input
=
*
(
int
*
)
arg
;
if
(
input
==
VPFE_AMUX_COMPONENT
)
{
if
(
tvp7000_device_init
(
NULL
))
if
(
tvp7000_device_init
(
NULL
))
ret
=
-
EBUSY
;
}
else
...
...
@@ -730,7 +730,7 @@ static int tvp7000_device_cmd(u32 cmd, void *arg)
if
(
params
->
amuxmode
==
VPFE_AMUX_COMPONENT
)
{
ret
=
tvp7000_setup_video_star
dard
(
STD
(
VIDEO480P60HZ
));
ret
=
tvp7000_setup_video_stan
dard
(
STD
(
VIDEO480P60HZ
));
}
else
ret
=
-
1
;
...
...
@@ -753,7 +753,7 @@ static int tvp7000_device_init(struct vpfe_capture_params *params)
/* initialize TVP7000 as its default values */
tvp7000_write_inittab
(
tvp7000_init_default
,
NUM_OF_REGS
(
tvp7000_init_default
));
tvp7000_write_inittab
(
tvp7000_init_component
,
NUM_OF_REGS
(
tvp7000_init_component
));
if
(
tvp7000_selmux
())
if
(
tvp7000_selmux
())
return
-
1
;
return
0
;
}
...
...
@@ -804,14 +804,16 @@ static __init int tvp7000_init(void)
break
;
}
}
if
(
err
)
{
if
(
err
)
{
DPRINTK
(
"I2C driver %s add failed
\n
"
,
tvp7000_driver
.
driver
.
name
);
return
err
;
}
err
=
vpfe_capture_device_register
(
&
tvp7000_capture_device
);
if
(
err
)
{
if
(
err
)
{
DPRINTK
(
"VPFE Capture Device %s register failed
\n
"
,
tvp7000_capture_device
.
name
);
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