1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * stk-webcam.h : Driver for Syntek 1125 USB webcam controller
5 * Copyright (C) 2006 Nicolas VIVIEN
6 * Copyright 2007-2008 Jaime Velasco Juan <jsagarribay@gmail.com>
12 #include <linux/usb.h>
13 #include <media/v4l2-device.h>
14 #include <media/v4l2-ctrls.h>
15 #include <media/v4l2-common.h>
17 #define DRIVER_VERSION "v0.0.1"
18 #define DRIVER_VERSION_NUM 0x000001
20 #define MAX_ISO_BUFS 3
21 #define ISO_FRAMES_PER_DESC 16
22 #define ISO_MAX_FRAME_SIZE 3 * 1024
23 #define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
32 /* Streaming IO buffers */
33 struct stk_sio_buffer
{
34 struct v4l2_buffer v4lbuf
;
37 struct stk_camera
*dev
;
38 struct list_head list
;
41 enum stk_mode
{MODE_VGA
, MODE_SXGA
, MODE_CIF
, MODE_QVGA
, MODE_QCIF
};
56 #define is_present(dev) ((dev)->status & S_PRESENT)
57 #define is_initialised(dev) ((dev)->status & S_INITIALISED)
58 #define is_streaming(dev) ((dev)->status & S_STREAMING)
59 #define is_memallocd(dev) ((dev)->status & S_MEMALLOCD)
60 #define set_present(dev) ((dev)->status = S_PRESENT)
61 #define unset_present(dev) ((dev)->status &= \
62 ~(S_PRESENT|S_INITIALISED|S_STREAMING))
63 #define set_initialised(dev) ((dev)->status |= S_INITIALISED)
64 #define unset_initialised(dev) ((dev)->status &= ~S_INITIALISED)
65 #define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD)
66 #define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD)
67 #define set_streaming(dev) ((dev)->status |= S_STREAMING)
68 #define unset_streaming(dev) ((dev)->status &= ~S_STREAMING)
76 struct v4l2_device v4l2_dev
;
77 struct v4l2_ctrl_handler hdl
;
78 struct video_device vdev
;
79 struct usb_device
*udev
;
80 struct usb_interface
*interface
;
88 /* Not sure if this is right */
91 struct stk_video vsettings
;
93 enum stk_status status
;
96 wait_queue_head_t wait_frame
;
98 struct stk_iso_buf
*isobufs
;
101 /* Streaming buffers */
103 unsigned int n_sbufs
;
104 struct stk_sio_buffer
*sio_bufs
;
105 struct list_head sio_avail
;
106 struct list_head sio_full
;
110 #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
112 int stk_camera_write_reg(struct stk_camera
*, u16
, u8
);
113 int stk_camera_read_reg(struct stk_camera
*, u16
, u8
*);
115 int stk_sensor_init(struct stk_camera
*);
116 int stk_sensor_configure(struct stk_camera
*);
117 int stk_sensor_sleep(struct stk_camera
*dev
);
118 int stk_sensor_wakeup(struct stk_camera
*dev
);
119 int stk_sensor_set_brightness(struct stk_camera
*dev
, int br
);