Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * stk-webcam.h : Driver for Syntek 1125 USB webcam controller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2006 Nicolas VIVIEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright 2007-2008 Jaime Velasco Juan <jsagarribay@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifndef STKWEBCAM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define STKWEBCAM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <media/v4l2-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <media/v4l2-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <media/v4l2-common.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define DRIVER_VERSION		"v0.0.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define DRIVER_VERSION_NUM	0x000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define MAX_ISO_BUFS		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define ISO_FRAMES_PER_DESC	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define ISO_MAX_FRAME_SIZE	3 * 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define ISO_BUFFER_SIZE		(ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) struct stk_iso_buf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	int length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	int read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct urb *urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /* Streaming IO buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct stk_sio_buffer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct v4l2_buffer v4lbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	char *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int mapcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct stk_camera *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) enum stk_mode {MODE_VGA, MODE_SXGA, MODE_CIF, MODE_QVGA, MODE_QCIF};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct stk_video {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	enum stk_mode mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	__u32 palette;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	int hflip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	int vflip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) enum stk_status {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	S_PRESENT = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	S_INITIALISED = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	S_MEMALLOCD = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	S_STREAMING = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define is_present(dev)		((dev)->status & S_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define is_initialised(dev)	((dev)->status & S_INITIALISED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define is_streaming(dev)	((dev)->status & S_STREAMING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define is_memallocd(dev)	((dev)->status & S_MEMALLOCD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define set_present(dev)	((dev)->status = S_PRESENT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define unset_present(dev)	((dev)->status &= \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 					~(S_PRESENT|S_INITIALISED|S_STREAMING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define set_initialised(dev)	((dev)->status |= S_INITIALISED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define unset_initialised(dev)	((dev)->status &= ~S_INITIALISED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define set_memallocd(dev)	((dev)->status |= S_MEMALLOCD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define unset_memallocd(dev)	((dev)->status &= ~S_MEMALLOCD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define set_streaming(dev)	((dev)->status |= S_STREAMING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #define unset_streaming(dev)	((dev)->status &= ~S_STREAMING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) struct regval {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	unsigned reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	unsigned val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) struct stk_camera {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct v4l2_device v4l2_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	struct v4l2_ctrl_handler hdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	struct video_device vdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	struct usb_device *udev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct usb_interface *interface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	int webcam_model;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct file *owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	int first_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	u8 isoc_ep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	/* Not sure if this is right */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	atomic_t urbs_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	struct stk_video vsettings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	enum stk_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	spinlock_t spinlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	wait_queue_head_t wait_frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	struct stk_iso_buf *isobufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	int frame_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	/* Streaming buffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	int reading;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	unsigned int n_sbufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	struct stk_sio_buffer *sio_bufs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct list_head sio_avail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	struct list_head sio_full;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	unsigned sequence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int stk_camera_write_reg(struct stk_camera *, u16, u8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int stk_camera_read_reg(struct stk_camera *, u16, u8 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int stk_sensor_init(struct stk_camera *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int stk_sensor_configure(struct stk_camera *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int stk_sensor_sleep(struct stk_camera *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int stk_sensor_wakeup(struct stk_camera *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int stk_sensor_set_brightness(struct stk_camera *dev, int br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #endif