Merge tag 'regmap-fix-v5.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux/fpc-iii.git] / drivers / media / usb / stkwebcam / stk-webcam.h
blob14519e5308b18fb53708403a0d298b7ac06d4e48
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
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>
7 */
9 #ifndef STKWEBCAM_H
10 #define STKWEBCAM_H
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)
25 struct stk_iso_buf {
26 void *data;
27 int length;
28 int read;
29 struct urb *urb;
32 /* Streaming IO buffers */
33 struct stk_sio_buffer {
34 struct v4l2_buffer v4lbuf;
35 char *buffer;
36 int mapcount;
37 struct stk_camera *dev;
38 struct list_head list;
41 enum stk_mode {MODE_VGA, MODE_SXGA, MODE_CIF, MODE_QVGA, MODE_QCIF};
43 struct stk_video {
44 enum stk_mode mode;
45 __u32 palette;
46 int hflip;
47 int vflip;
50 enum stk_status {
51 S_PRESENT = 1,
52 S_INITIALISED = 2,
53 S_MEMALLOCD = 4,
54 S_STREAMING = 8,
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)
70 struct regval {
71 unsigned reg;
72 unsigned val;
75 struct stk_camera {
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;
81 int webcam_model;
82 struct file *owner;
83 struct mutex lock;
84 int first_init;
86 u8 isoc_ep;
88 /* Not sure if this is right */
89 atomic_t urbs_used;
91 struct stk_video vsettings;
93 enum stk_status status;
95 spinlock_t spinlock;
96 wait_queue_head_t wait_frame;
98 struct stk_iso_buf *isobufs;
100 int frame_size;
101 /* Streaming buffers */
102 int reading;
103 unsigned int n_sbufs;
104 struct stk_sio_buffer *sio_bufs;
105 struct list_head sio_avail;
106 struct list_head sio_full;
107 unsigned sequence;
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);
121 #endif