]>
Commit | Line | Data |
---|---|---|
ec16dae5 JVJ |
1 | /* |
2 | * stk-webcam.h : Driver for Syntek 1125 USB webcam controller | |
3 | * | |
4 | * Copyright (C) 2006 Nicolas VIVIEN | |
5 | * Copyright 2007-2008 Jaime Velasco Juan <jsagarribay@gmail.com> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
ec16dae5 JVJ |
16 | */ |
17 | ||
18 | #ifndef STKWEBCAM_H | |
19 | #define STKWEBCAM_H | |
20 | ||
21 | #include <linux/usb.h> | |
968c60f6 | 22 | #include <media/v4l2-device.h> |
dc0fb286 | 23 | #include <media/v4l2-ctrls.h> |
ec16dae5 JVJ |
24 | #include <media/v4l2-common.h> |
25 | ||
26 | #define DRIVER_VERSION "v0.0.1" | |
27 | #define DRIVER_VERSION_NUM 0x000001 | |
28 | ||
29 | #define MAX_ISO_BUFS 3 | |
30 | #define ISO_FRAMES_PER_DESC 16 | |
31 | #define ISO_MAX_FRAME_SIZE 3 * 1024 | |
32 | #define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE) | |
33 | ||
ec16dae5 JVJ |
34 | struct stk_iso_buf { |
35 | void *data; | |
36 | int length; | |
37 | int read; | |
38 | struct urb *urb; | |
39 | }; | |
40 | ||
41 | /* Streaming IO buffers */ | |
42 | struct stk_sio_buffer { | |
43 | struct v4l2_buffer v4lbuf; | |
44 | char *buffer; | |
45 | int mapcount; | |
46 | struct stk_camera *dev; | |
47 | struct list_head list; | |
48 | }; | |
49 | ||
50 | enum stk_mode {MODE_VGA, MODE_SXGA, MODE_CIF, MODE_QVGA, MODE_QCIF}; | |
51 | ||
52 | struct stk_video { | |
53 | enum stk_mode mode; | |
ec16dae5 JVJ |
54 | __u32 palette; |
55 | int hflip; | |
56 | int vflip; | |
57 | }; | |
58 | ||
59 | enum stk_status { | |
60 | S_PRESENT = 1, | |
61 | S_INITIALISED = 2, | |
62 | S_MEMALLOCD = 4, | |
63 | S_STREAMING = 8, | |
64 | }; | |
65 | #define is_present(dev) ((dev)->status & S_PRESENT) | |
66 | #define is_initialised(dev) ((dev)->status & S_INITIALISED) | |
67 | #define is_streaming(dev) ((dev)->status & S_STREAMING) | |
68 | #define is_memallocd(dev) ((dev)->status & S_MEMALLOCD) | |
69 | #define set_present(dev) ((dev)->status = S_PRESENT) | |
70 | #define unset_present(dev) ((dev)->status &= \ | |
71 | ~(S_PRESENT|S_INITIALISED|S_STREAMING)) | |
72 | #define set_initialised(dev) ((dev)->status |= S_INITIALISED) | |
1fdd61c0 | 73 | #define unset_initialised(dev) ((dev)->status &= ~S_INITIALISED) |
ec16dae5 JVJ |
74 | #define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD) |
75 | #define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD) | |
76 | #define set_streaming(dev) ((dev)->status |= S_STREAMING) | |
77 | #define unset_streaming(dev) ((dev)->status &= ~S_STREAMING) | |
78 | ||
79 | struct regval { | |
80 | unsigned reg; | |
81 | unsigned val; | |
82 | }; | |
83 | ||
84 | struct stk_camera { | |
968c60f6 | 85 | struct v4l2_device v4l2_dev; |
dc0fb286 | 86 | struct v4l2_ctrl_handler hdl; |
ec16dae5 JVJ |
87 | struct video_device vdev; |
88 | struct usb_device *udev; | |
89 | struct usb_interface *interface; | |
90 | int webcam_model; | |
91 | struct file *owner; | |
f80daa2d | 92 | struct mutex lock; |
89ea4706 | 93 | int first_init; |
ec16dae5 JVJ |
94 | |
95 | u8 isoc_ep; | |
96 | ||
ec16dae5 JVJ |
97 | /* Not sure if this is right */ |
98 | atomic_t urbs_used; | |
99 | ||
100 | struct stk_video vsettings; | |
101 | ||
102 | enum stk_status status; | |
103 | ||
104 | spinlock_t spinlock; | |
105 | wait_queue_head_t wait_frame; | |
106 | ||
107 | struct stk_iso_buf *isobufs; | |
108 | ||
109 | int frame_size; | |
110 | /* Streaming buffers */ | |
1b499fe5 | 111 | int reading; |
ec16dae5 JVJ |
112 | unsigned int n_sbufs; |
113 | struct stk_sio_buffer *sio_bufs; | |
114 | struct list_head sio_avail; | |
115 | struct list_head sio_full; | |
116 | unsigned sequence; | |
117 | }; | |
118 | ||
ec16dae5 JVJ |
119 | #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev) |
120 | ||
ec16dae5 | 121 | int stk_camera_write_reg(struct stk_camera *, u16, u8); |
d08876f5 | 122 | int stk_camera_read_reg(struct stk_camera *, u16, u8 *); |
ec16dae5 | 123 | |
ec16dae5 JVJ |
124 | int stk_sensor_init(struct stk_camera *); |
125 | int stk_sensor_configure(struct stk_camera *); | |
126 | int stk_sensor_sleep(struct stk_camera *dev); | |
127 | int stk_sensor_wakeup(struct stk_camera *dev); | |
128 | int stk_sensor_set_brightness(struct stk_camera *dev, int br); | |
129 | ||
130 | #endif |