Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
27b350ef
Commit
27b350ef
authored
Mar 14, 2002
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Automerge
parents
2e8a9bc4
b64b9783
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
124 deletions
+100
-124
drivers/media/video/meye.c
drivers/media/video/meye.c
+99
-122
drivers/media/video/meye.h
drivers/media/video/meye.h
+1
-2
No files found.
drivers/media/video/meye.c
View file @
27b350ef
...
...
@@ -868,124 +868,108 @@ static void meye_irq(int irq, void *dev_id, struct pt_regs *regs) {
/* video4linux integration */
/****************************************************************************/
static
int
meye_open
(
struct
video_device
*
dev
,
int
flags
)
{
int
i
;
static
int
meye_open
(
struct
inode
*
inode
,
struct
file
*
file
)
{
int
i
,
err
;
down
(
&
meye
.
lock
);
if
(
meye
.
open_count
)
{
up
(
&
meye
.
lock
);
return
-
EBUSY
;
}
meye
.
open_count
++
;
err
=
video_exclusive_open
(
inode
,
file
);
if
(
err
<
0
)
return
err
;
if
(
mchip_dma_alloc
())
{
printk
(
KERN_ERR
"meye: mchip framebuffer allocation failed
\n
"
);
up
(
&
meye
.
lock
);
video_exclusive_release
(
inode
,
file
);
return
-
ENOBUFS
;
}
mchip_hic_stop
();
meye_initq
(
&
meye
.
grabq
);
for
(
i
=
0
;
i
<
MEYE_MAX_BUFNBRS
;
i
++
)
meye
.
grab_buffer
[
i
].
state
=
MEYE_BUF_UNUSED
;
up
(
&
meye
.
lock
);
return
0
;
}
static
void
meye_close
(
struct
video_device
*
dev
)
{
down
(
&
meye
.
lock
);
meye
.
open_count
--
;
static
int
meye_release
(
struct
inode
*
inode
,
struct
file
*
file
)
{
mchip_hic_stop
();
up
(
&
meye
.
lock
);
video_exclusive_release
(
inode
,
file
);
return
0
;
}
static
int
meye_ioctl
(
struct
video_device
*
dev
,
unsigned
int
cmd
,
void
*
arg
)
{
static
int
meye_ioctl
(
struct
inode
*
inode
,
struct
file
*
file
,
unsigned
int
cmd
,
void
*
arg
)
{
switch
(
cmd
)
{
case
VIDIOCGCAP
:
{
struct
video_capability
b
;
strcpy
(
b
.
name
,
meye
.
video_dev
.
name
);
b
.
type
=
VID_TYPE_CAPTURE
;
b
.
channels
=
1
;
b
.
audios
=
0
;
b
.
maxwidth
=
640
;
b
.
maxheight
=
480
;
b
.
minwidth
=
320
;
b
.
minheight
=
240
;
if
(
copy_to_user
(
arg
,
&
b
,
sizeof
(
b
)))
return
-
EFAULT
;
struct
video_capability
*
b
=
arg
;
strcpy
(
b
->
name
,
meye
.
video_dev
.
name
);
b
->
type
=
VID_TYPE_CAPTURE
;
b
->
channels
=
1
;
b
->
audios
=
0
;
b
->
maxwidth
=
640
;
b
->
maxheight
=
480
;
b
->
minwidth
=
320
;
b
->
minheight
=
240
;
break
;
}
case
VIDIOCGCHAN
:
{
struct
video_channel
v
;
if
(
copy_from_user
(
&
v
,
arg
,
sizeof
(
v
)))
return
-
EFAULT
;
v
.
flags
=
0
;
v
.
tuners
=
0
;
v
.
type
=
VIDEO_TYPE_CAMERA
;
if
(
v
.
channel
!=
0
)
struct
video_channel
*
v
=
arg
;
v
->
flags
=
0
;
v
->
tuners
=
0
;
v
->
type
=
VIDEO_TYPE_CAMERA
;
if
(
v
->
channel
!=
0
)
return
-
EINVAL
;
strcpy
(
v
.
name
,
"Camera"
);
if
(
copy_to_user
(
arg
,
&
v
,
sizeof
(
v
)))
return
-
EFAULT
;
strcpy
(
v
->
name
,
"Camera"
);
break
;
}
case
VIDIOCSCHAN
:
{
struct
video_channel
v
;
if
(
copy_from_user
(
&
v
,
arg
,
sizeof
(
v
)))
return
-
EFAULT
;
if
(
v
.
channel
!=
0
)
struct
video_channel
*
v
=
arg
;
if
(
v
->
channel
!=
0
)
return
-
EINVAL
;
break
;
}
case
VIDIOCGPICT
:
{
struct
video_picture
p
=
meye
.
picture
;
if
(
copy_to_user
(
arg
,
&
p
,
sizeof
(
p
)))
return
-
EFAULT
;
struct
video_picture
*
p
=
arg
;
*
p
=
meye
.
picture
;
break
;
}
case
VIDIOCSPICT
:
{
struct
video_picture
p
;
if
(
copy_from_user
(
&
p
,
arg
,
sizeof
(
p
)))
return
-
EFAULT
;
if
(
p
.
depth
!=
2
)
struct
video_picture
*
p
=
arg
;
if
(
p
->
depth
!=
2
)
return
-
EINVAL
;
if
(
p
.
palette
!=
VIDEO_PALETTE_YUV422
)
if
(
p
->
palette
!=
VIDEO_PALETTE_YUV422
)
return
-
EINVAL
;
down
(
&
meye
.
lock
);
sonypi_camera_command
(
SONYPI_COMMAND_SETCAMERABRIGHTNESS
,
p
.
brightness
>>
10
);
p
->
brightness
>>
10
);
sonypi_camera_command
(
SONYPI_COMMAND_SETCAMERAHUE
,
p
.
hue
>>
10
);
p
->
hue
>>
10
);
sonypi_camera_command
(
SONYPI_COMMAND_SETCAMERACOLOR
,
p
.
colour
>>
10
);
p
->
colour
>>
10
);
sonypi_camera_command
(
SONYPI_COMMAND_SETCAMERACONTRAST
,
p
.
contrast
>>
10
);
me
mcpy
(
&
meye
.
picture
,
&
p
,
sizeof
(
p
))
;
p
->
contrast
>>
10
);
me
ye
.
picture
=
*
p
;
up
(
&
meye
.
lock
);
break
;
}
case
VIDIOCSYNC
:
{
int
i
;
int
*
i
=
arg
;
DECLARE_WAITQUEUE
(
wait
,
current
);
if
(
copy_from_user
((
void
*
)
&
i
,
arg
,
sizeof
(
int
)))
return
-
EFAULT
;
if
(
i
<
0
||
i
>=
gbuffers
)
if
(
*
i
<
0
||
*
i
>=
gbuffers
)
return
-
EINVAL
;
switch
(
meye
.
grab_buffer
[
i
].
state
)
{
switch
(
meye
.
grab_buffer
[
*
i
].
state
)
{
case
MEYE_BUF_UNUSED
:
return
-
EINVAL
;
case
MEYE_BUF_USING
:
add_wait_queue
(
&
meye
.
grabq
.
proc_list
,
&
wait
);
current
->
state
=
TASK_INTERRUPTIBLE
;
while
(
meye
.
grab_buffer
[
i
].
state
==
MEYE_BUF_USING
)
{
while
(
meye
.
grab_buffer
[
*
i
].
state
==
MEYE_BUF_USING
)
{
schedule
();
if
(
signal_pending
(
current
))
{
remove_wait_queue
(
&
meye
.
grabq
.
proc_list
,
&
wait
);
...
...
@@ -997,36 +981,34 @@ static int meye_ioctl(struct video_device *dev, unsigned int cmd, void *arg) {
current
->
state
=
TASK_RUNNING
;
/* fall through */
case
MEYE_BUF_DONE
:
meye
.
grab_buffer
[
i
].
state
=
MEYE_BUF_UNUSED
;
meye
.
grab_buffer
[
*
i
].
state
=
MEYE_BUF_UNUSED
;
}
break
;
}
case
VIDIOCMCAPTURE
:
{
struct
video_mmap
vm
;
struct
video_mmap
*
vm
=
arg
;
int
restart
=
0
;
if
(
copy_from_user
((
void
*
)
&
vm
,
(
void
*
)
arg
,
sizeof
(
vm
)))
return
-
EFAULT
;
if
(
vm
.
frame
>=
gbuffers
||
vm
.
frame
<
0
)
if
(
vm
->
frame
>=
gbuffers
||
vm
->
frame
<
0
)
return
-
EINVAL
;
if
(
vm
.
format
!=
VIDEO_PALETTE_YUV422
)
if
(
vm
->
format
!=
VIDEO_PALETTE_YUV422
)
return
-
EINVAL
;
if
(
vm
.
height
*
vm
.
width
*
2
>
gbufsize
)
if
(
vm
->
height
*
vm
->
width
*
2
>
gbufsize
)
return
-
EINVAL
;
if
(
!
meye
.
grab_fbuffer
)
return
-
EINVAL
;
if
(
meye
.
grab_buffer
[
vm
.
frame
].
state
!=
MEYE_BUF_UNUSED
)
if
(
meye
.
grab_buffer
[
vm
->
frame
].
state
!=
MEYE_BUF_UNUSED
)
return
-
EBUSY
;
down
(
&
meye
.
lock
);
if
(
vm
.
width
==
640
&&
vm
.
height
==
480
)
{
if
(
vm
->
width
==
640
&&
vm
->
height
==
480
)
{
if
(
meye
.
params
.
subsample
)
{
meye
.
params
.
subsample
=
0
;
restart
=
1
;
}
}
else
if
(
vm
.
width
==
320
&&
vm
.
height
==
240
)
{
else
if
(
vm
->
width
==
320
&&
vm
->
height
==
240
)
{
if
(
!
meye
.
params
.
subsample
)
{
meye
.
params
.
subsample
=
1
;
restart
=
1
;
...
...
@@ -1039,49 +1021,45 @@ static int meye_ioctl(struct video_device *dev, unsigned int cmd, void *arg) {
if
(
restart
||
meye
.
mchip_mode
!=
MCHIP_HIC_MODE_CONT_OUT
)
mchip_continuous_start
();
meye
.
grab_buffer
[
vm
.
frame
].
state
=
MEYE_BUF_USING
;
meye_pushq
(
&
meye
.
grabq
,
vm
.
frame
);
meye
.
grab_buffer
[
vm
->
frame
].
state
=
MEYE_BUF_USING
;
meye_pushq
(
&
meye
.
grabq
,
vm
->
frame
);
up
(
&
meye
.
lock
);
break
;
}
case
VIDIOCGMBUF
:
{
struct
video_mbuf
vm
;
struct
video_mbuf
*
vm
=
arg
;
int
i
;
memset
(
&
vm
,
0
,
sizeof
(
vm
));
vm
.
size
=
gbufsize
*
gbuffers
;
vm
.
frames
=
gbuffers
;
memset
(
vm
,
0
,
sizeof
(
*
vm
));
vm
->
size
=
gbufsize
*
gbuffers
;
vm
->
frames
=
gbuffers
;
for
(
i
=
0
;
i
<
gbuffers
;
i
++
)
vm
.
offsets
[
i
]
=
i
*
gbufsize
;
if
(
copy_to_user
((
void
*
)
arg
,
(
void
*
)
&
vm
,
sizeof
(
vm
)))
return
-
EFAULT
;
vm
->
offsets
[
i
]
=
i
*
gbufsize
;
break
;
}
case
MEYEIOC_G_PARAMS
:
{
if
(
copy_to_user
(
arg
,
&
meye
.
params
,
sizeof
(
meye
.
params
)))
return
-
EFAULT
;
struct
meye_params
*
p
=
arg
;
*
p
=
meye
.
params
;
break
;
}
case
MEYEIOC_S_PARAMS
:
{
struct
meye_params
jp
;
if
(
copy_from_user
(
&
jp
,
arg
,
sizeof
(
jp
)))
return
-
EFAULT
;
if
(
jp
.
subsample
>
1
)
struct
meye_params
*
jp
=
arg
;
if
(
jp
->
subsample
>
1
)
return
-
EINVAL
;
if
(
jp
.
quality
>
10
)
if
(
jp
->
quality
>
10
)
return
-
EINVAL
;
if
(
jp
.
sharpness
>
63
||
jp
.
agc
>
63
||
jp
.
picture
>
63
)
if
(
jp
->
sharpness
>
63
||
jp
->
agc
>
63
||
jp
->
picture
>
63
)
return
-
EINVAL
;
if
(
jp
.
framerate
>
31
)
if
(
jp
->
framerate
>
31
)
return
-
EINVAL
;
down
(
&
meye
.
lock
);
if
(
meye
.
params
.
subsample
!=
jp
.
subsample
||
meye
.
params
.
quality
!=
jp
.
quality
)
if
(
meye
.
params
.
subsample
!=
jp
->
subsample
||
meye
.
params
.
quality
!=
jp
->
quality
)
mchip_hic_stop
();
/* need restart */
me
mcpy
(
&
meye
.
params
,
&
jp
,
sizeof
(
jp
))
;
me
ye
.
params
=
*
jp
;
sonypi_camera_command
(
SONYPI_COMMAND_SETCAMERASHARPNESS
,
meye
.
params
.
sharpness
);
sonypi_camera_command
(
SONYPI_COMMAND_SETCAMERAAGC
,
...
...
@@ -1093,48 +1071,43 @@ static int meye_ioctl(struct video_device *dev, unsigned int cmd, void *arg) {
}
case
MEYEIOC_QBUF_CAPT
:
{
int
nb
;
if
(
copy_from_user
((
void
*
)
&
nb
,
(
void
*
)
arg
,
sizeof
(
int
)))
return
-
EFAULT
;
int
*
nb
=
arg
;
if
(
!
meye
.
grab_fbuffer
)
return
-
EINVAL
;
if
(
nb
>=
gbuffers
)
if
(
*
nb
>=
gbuffers
)
return
-
EINVAL
;
if
(
nb
<
0
)
{
if
(
*
nb
<
0
)
{
/* stop capture */
mchip_hic_stop
();
return
0
;
}
if
(
meye
.
grab_buffer
[
nb
].
state
!=
MEYE_BUF_UNUSED
)
if
(
meye
.
grab_buffer
[
*
nb
].
state
!=
MEYE_BUF_UNUSED
)
return
-
EBUSY
;
down
(
&
meye
.
lock
);
if
(
meye
.
mchip_mode
!=
MCHIP_HIC_MODE_CONT_COMP
)
mchip_cont_compression_start
();
meye
.
grab_buffer
[
nb
].
state
=
MEYE_BUF_USING
;
meye_pushq
(
&
meye
.
grabq
,
nb
);
meye
.
grab_buffer
[
*
nb
].
state
=
MEYE_BUF_USING
;
meye_pushq
(
&
meye
.
grabq
,
*
nb
);
up
(
&
meye
.
lock
);
break
;
}
case
MEYEIOC_SYNC
:
{
int
i
;
int
*
i
=
arg
;
DECLARE_WAITQUEUE
(
wait
,
current
);
if
(
copy_from_user
((
void
*
)
&
i
,
arg
,
sizeof
(
int
)))
return
-
EFAULT
;
if
(
i
<
0
||
i
>=
gbuffers
)
if
(
*
i
<
0
||
*
i
>=
gbuffers
)
return
-
EINVAL
;
switch
(
meye
.
grab_buffer
[
i
].
state
)
{
switch
(
meye
.
grab_buffer
[
*
i
].
state
)
{
case
MEYE_BUF_UNUSED
:
return
-
EINVAL
;
case
MEYE_BUF_USING
:
add_wait_queue
(
&
meye
.
grabq
.
proc_list
,
&
wait
);
current
->
state
=
TASK_INTERRUPTIBLE
;
while
(
meye
.
grab_buffer
[
i
].
state
==
MEYE_BUF_USING
)
{
while
(
meye
.
grab_buffer
[
*
i
].
state
==
MEYE_BUF_USING
)
{
schedule
();
if
(
signal_pending
(
current
))
{
remove_wait_queue
(
&
meye
.
grabq
.
proc_list
,
&
wait
);
...
...
@@ -1146,11 +1119,9 @@ static int meye_ioctl(struct video_device *dev, unsigned int cmd, void *arg) {
current
->
state
=
TASK_RUNNING
;
/* fall through */
case
MEYE_BUF_DONE
:
meye
.
grab_buffer
[
i
].
state
=
MEYE_BUF_UNUSED
;
meye
.
grab_buffer
[
*
i
].
state
=
MEYE_BUF_UNUSED
;
}
i
=
meye
.
grab_buffer
[
i
].
size
;
if
(
copy_to_user
(
arg
,
(
void
*
)
&
i
,
sizeof
(
int
)))
return
-
EFAULT
;
*
i
=
meye
.
grab_buffer
[
*
i
].
size
;
break
;
}
...
...
@@ -1172,7 +1143,7 @@ static int meye_ioctl(struct video_device *dev, unsigned int cmd, void *arg) {
}
case
MEYEIOC_STILLJCAPT
:
{
int
len
=
-
1
;
int
*
len
=
arg
;
if
(
!
meye
.
grab_fbuffer
)
return
-
EINVAL
;
...
...
@@ -1180,14 +1151,13 @@ static int meye_ioctl(struct video_device *dev, unsigned int cmd, void *arg) {
return
-
EBUSY
;
down
(
&
meye
.
lock
);
meye
.
grab_buffer
[
0
].
state
=
MEYE_BUF_USING
;
while
(
len
==
-
1
)
{
*
len
=
-
1
;
while
(
*
len
==
-
1
)
{
mchip_take_picture
();
len
=
mchip_compress_frame
(
meye
.
grab_fbuffer
,
gbufsize
);
*
len
=
mchip_compress_frame
(
meye
.
grab_fbuffer
,
gbufsize
);
}
meye
.
grab_buffer
[
0
].
state
=
MEYE_BUF_DONE
;
up
(
&
meye
.
lock
);
if
(
copy_to_user
(
arg
,
(
void
*
)
&
len
,
sizeof
(
int
)))
return
-
EFAULT
;
break
;
}
...
...
@@ -1199,10 +1169,10 @@ static int meye_ioctl(struct video_device *dev, unsigned int cmd, void *arg) {
return
0
;
}
static
int
meye_mmap
(
struct
vm_area_struct
*
vma
,
struct
video_device
*
dev
,
const
char
*
adr
,
unsigned
long
size
)
{
unsigned
long
s
tart
=
(
unsigned
long
)
adr
;
unsigned
long
page
,
pos
;
static
int
meye_mmap
(
struct
file
*
file
,
struct
vm_area_struct
*
vma
)
{
unsigned
long
start
=
vma
->
vm_start
;
unsigned
long
s
ize
=
vma
->
vm_end
-
vma
->
vm_start
;
unsigned
long
page
,
pos
;
down
(
&
meye
.
lock
);
if
(
size
>
gbuffers
*
gbufsize
)
{
...
...
@@ -1234,15 +1204,22 @@ static int meye_mmap(struct vm_area_struct *vma, struct video_device *dev, const
return
0
;
}
static
struct
file_operations
meye_fops
=
{
owner:
THIS_MODULE
,
open:
meye_open
,
release:
meye_release
,
mmap:
meye_mmap
,
ioctl:
video_generic_ioctl
,
llseek:
no_llseek
,
};
static
struct
video_device
meye_template
=
{
owner:
THIS_MODULE
,
name:
"meye"
,
type:
VID_TYPE_CAPTURE
,
hardware:
VID_HARDWARE_MEYE
,
open:
meye_open
,
close:
meye_close
,
ioctl:
meye_ioctl
,
mmap:
meye_mmap
,
fops:
&
meye_fops
,
kernel_ioctl:
meye_ioctl
,
};
static
int
__devinit
meye_probe
(
struct
pci_dev
*
pcidev
,
...
...
drivers/media/video/meye.h
View file @
27b350ef
...
...
@@ -29,7 +29,7 @@
#define _MEYE_PRIV_H_
#define MEYE_DRIVER_MAJORVERSION 1
#define MEYE_DRIVER_MINORVERSION
2
#define MEYE_DRIVER_MINORVERSION
3
/****************************************************************************/
/* Motion JPEG chip registers */
...
...
@@ -300,7 +300,6 @@ struct meye {
struct
meye_grab_buffer
grab_buffer
[
MEYE_MAX_BUFNBRS
];
/* other */
unsigned
int
open_count
;
/* open() count */
struct
semaphore
lock
;
/* semaphore for open/mmap... */
struct
meye_queue
grabq
;
/* queue for buffers to be grabbed */
...
...
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