2019-05-27 13:55:21 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2008-02-16 07:53:09 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2005-2006 Micronas USA Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the private include file for the go7007 driver. It should not
|
|
|
|
* be included by anybody but the driver itself, and especially not by
|
|
|
|
* user-space applications.
|
|
|
|
*/
|
|
|
|
|
2009-11-17 01:07:42 +07:00
|
|
|
#include <media/v4l2-device.h>
|
2013-03-11 15:19:59 +07:00
|
|
|
#include <media/v4l2-ctrls.h>
|
2013-03-09 21:08:41 +07:00
|
|
|
#include <media/v4l2-fh.h>
|
2015-09-22 20:30:29 +07:00
|
|
|
#include <media/videobuf2-v4l2.h>
|
2009-11-17 01:07:42 +07:00
|
|
|
|
2008-02-16 07:53:09 +07:00
|
|
|
struct go7007;
|
|
|
|
|
|
|
|
/* IDs to activate board-specific support code */
|
|
|
|
#define GO7007_BOARDID_MATRIX_II 0
|
|
|
|
#define GO7007_BOARDID_MATRIX_RELOAD 1
|
|
|
|
#define GO7007_BOARDID_STAR_TREK 2
|
|
|
|
#define GO7007_BOARDID_PCI_VOYAGER 3
|
|
|
|
#define GO7007_BOARDID_XMEN 4
|
|
|
|
#define GO7007_BOARDID_XMEN_II 5
|
|
|
|
#define GO7007_BOARDID_XMEN_III 6
|
|
|
|
#define GO7007_BOARDID_MATRIX_REV 7
|
2013-03-11 16:11:03 +07:00
|
|
|
#define GO7007_BOARDID_PX_M402U 8
|
|
|
|
#define GO7007_BOARDID_PX_TV402U 9
|
|
|
|
#define GO7007_BOARDID_LIFEVIEW_LR192 10 /* TV Walker Ultra */
|
|
|
|
#define GO7007_BOARDID_ENDURA 11
|
|
|
|
#define GO7007_BOARDID_ADLINK_MPG24 12
|
|
|
|
#define GO7007_BOARDID_SENSORAY_2250 13 /* Sensoray 2250/2251 */
|
2013-03-17 20:15:03 +07:00
|
|
|
#define GO7007_BOARDID_ADS_USBAV_709 14
|
2008-02-16 07:53:09 +07:00
|
|
|
|
|
|
|
/* Various characteristics of each board */
|
|
|
|
#define GO7007_BOARD_HAS_AUDIO (1<<0)
|
|
|
|
#define GO7007_BOARD_USE_ONBOARD_I2C (1<<1)
|
|
|
|
#define GO7007_BOARD_HAS_TUNER (1<<2)
|
|
|
|
|
|
|
|
/* Characteristics of sensor devices */
|
|
|
|
#define GO7007_SENSOR_VALID_POLAR (1<<0)
|
|
|
|
#define GO7007_SENSOR_HREF_POLAR (1<<1)
|
|
|
|
#define GO7007_SENSOR_VREF_POLAR (1<<2)
|
|
|
|
#define GO7007_SENSOR_FIELD_ID_POLAR (1<<3)
|
|
|
|
#define GO7007_SENSOR_BIT_WIDTH (1<<4)
|
|
|
|
#define GO7007_SENSOR_VALID_ENABLE (1<<5)
|
|
|
|
#define GO7007_SENSOR_656 (1<<6)
|
|
|
|
#define GO7007_SENSOR_CONFIG_MASK 0x7f
|
|
|
|
#define GO7007_SENSOR_TV (1<<7)
|
|
|
|
#define GO7007_SENSOR_VBI (1<<8)
|
|
|
|
#define GO7007_SENSOR_SCALING (1<<9)
|
2013-03-11 16:12:10 +07:00
|
|
|
#define GO7007_SENSOR_SAA7115 (1<<10)
|
2008-02-16 07:53:09 +07:00
|
|
|
|
|
|
|
/* Characteristics of audio sensor devices */
|
|
|
|
#define GO7007_AUDIO_I2S_MODE_1 (1)
|
|
|
|
#define GO7007_AUDIO_I2S_MODE_2 (2)
|
|
|
|
#define GO7007_AUDIO_I2S_MODE_3 (3)
|
|
|
|
#define GO7007_AUDIO_BCLK_POLAR (1<<2)
|
|
|
|
#define GO7007_AUDIO_WORD_14 (14<<4)
|
|
|
|
#define GO7007_AUDIO_WORD_16 (16<<4)
|
|
|
|
#define GO7007_AUDIO_ONE_CHANNEL (1<<11)
|
|
|
|
#define GO7007_AUDIO_I2S_MASTER (1<<16)
|
|
|
|
#define GO7007_AUDIO_OKI_MODE (1<<17)
|
|
|
|
|
2014-06-10 17:39:04 +07:00
|
|
|
#define GO7007_CID_CUSTOM_BASE (V4L2_CID_DETECT_CLASS_BASE + 0x1000)
|
|
|
|
#define V4L2_CID_PIXEL_THRESHOLD0 (GO7007_CID_CUSTOM_BASE+1)
|
|
|
|
#define V4L2_CID_MOTION_THRESHOLD0 (GO7007_CID_CUSTOM_BASE+2)
|
|
|
|
#define V4L2_CID_MB_THRESHOLD0 (GO7007_CID_CUSTOM_BASE+3)
|
|
|
|
#define V4L2_CID_PIXEL_THRESHOLD1 (GO7007_CID_CUSTOM_BASE+4)
|
|
|
|
#define V4L2_CID_MOTION_THRESHOLD1 (GO7007_CID_CUSTOM_BASE+5)
|
|
|
|
#define V4L2_CID_MB_THRESHOLD1 (GO7007_CID_CUSTOM_BASE+6)
|
|
|
|
#define V4L2_CID_PIXEL_THRESHOLD2 (GO7007_CID_CUSTOM_BASE+7)
|
|
|
|
#define V4L2_CID_MOTION_THRESHOLD2 (GO7007_CID_CUSTOM_BASE+8)
|
|
|
|
#define V4L2_CID_MB_THRESHOLD2 (GO7007_CID_CUSTOM_BASE+9)
|
|
|
|
#define V4L2_CID_PIXEL_THRESHOLD3 (GO7007_CID_CUSTOM_BASE+10)
|
|
|
|
#define V4L2_CID_MOTION_THRESHOLD3 (GO7007_CID_CUSTOM_BASE+11)
|
|
|
|
#define V4L2_CID_MB_THRESHOLD3 (GO7007_CID_CUSTOM_BASE+12)
|
|
|
|
|
2008-02-16 07:53:09 +07:00
|
|
|
struct go7007_board_info {
|
|
|
|
unsigned int flags;
|
|
|
|
int hpi_buffer_cap;
|
|
|
|
unsigned int sensor_flags;
|
|
|
|
int sensor_width;
|
|
|
|
int sensor_height;
|
|
|
|
int sensor_framerate;
|
|
|
|
int sensor_h_offset;
|
|
|
|
int sensor_v_offset;
|
|
|
|
unsigned int audio_flags;
|
|
|
|
int audio_rate;
|
|
|
|
int audio_bclk_div;
|
|
|
|
int audio_main_div;
|
|
|
|
int num_i2c_devs;
|
2013-03-09 18:48:25 +07:00
|
|
|
struct go_i2c {
|
2009-04-22 02:47:22 +07:00
|
|
|
const char *type;
|
2013-04-17 13:20:30 +07:00
|
|
|
unsigned int is_video:1;
|
|
|
|
unsigned int is_audio:1;
|
2008-02-16 07:53:09 +07:00
|
|
|
int addr;
|
2013-03-09 18:48:25 +07:00
|
|
|
u32 flags;
|
2013-03-09 19:25:47 +07:00
|
|
|
} i2c_devs[5];
|
2008-02-16 07:53:09 +07:00
|
|
|
int num_inputs;
|
|
|
|
struct {
|
|
|
|
int video_input;
|
2013-03-09 19:25:47 +07:00
|
|
|
int audio_index;
|
2008-02-16 07:53:09 +07:00
|
|
|
char *name;
|
|
|
|
} inputs[4];
|
2013-03-09 19:25:47 +07:00
|
|
|
int video_config;
|
|
|
|
int num_aud_inputs;
|
|
|
|
struct {
|
|
|
|
int audio_input;
|
|
|
|
char *name;
|
|
|
|
} aud_inputs[3];
|
2008-02-16 07:53:09 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct go7007_hpi_ops {
|
|
|
|
int (*interface_reset)(struct go7007 *go);
|
|
|
|
int (*write_interrupt)(struct go7007 *go, int addr, int data);
|
|
|
|
int (*read_interrupt)(struct go7007 *go);
|
|
|
|
int (*stream_start)(struct go7007 *go);
|
|
|
|
int (*stream_stop)(struct go7007 *go);
|
|
|
|
int (*send_firmware)(struct go7007 *go, u8 *data, int len);
|
2008-10-31 02:56:33 +07:00
|
|
|
int (*send_command)(struct go7007 *go, unsigned int cmd, void *arg);
|
2013-03-11 14:48:30 +07:00
|
|
|
void (*release)(struct go7007 *go);
|
2008-02-16 07:53:09 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* The video buffer size must be a multiple of PAGE_SIZE */
|
|
|
|
#define GO7007_BUF_PAGES (128 * 1024 / PAGE_SIZE)
|
|
|
|
#define GO7007_BUF_SIZE (GO7007_BUF_PAGES << PAGE_SHIFT)
|
|
|
|
|
|
|
|
struct go7007_buffer {
|
[media] media: videobuf2: Restructure vb2_buffer
Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer.
Add new member variables - bytesused, length, offset, userptr, fd,
data_offset - to struct vb2_plane in order to cover all information
of v4l2_plane.
struct vb2_plane {
<snip>
unsigned int bytesused;
unsigned int length;
union {
unsigned int offset;
unsigned long userptr;
int fd;
} m;
unsigned int data_offset;
}
Replace v4l2_buf with new member variables - index, type, memory - which
are common fields for buffer management.
struct vb2_buffer {
<snip>
unsigned int index;
unsigned int type;
unsigned int memory;
unsigned int num_planes;
struct vb2_plane planes[VIDEO_MAX_PLANES];
<snip>
};
v4l2 specific fields - flags, field, timestamp, timecode,
sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c
struct vb2_v4l2_buffer {
struct vb2_buffer vb2_buf;
__u32 flags;
__u32 field;
struct timeval timestamp;
struct v4l2_timecode timecode;
__u32 sequence;
};
Signed-off-by: Junghak Sung <jh1009.sung@samsung.com>
Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com>
Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Acked-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-09-22 20:30:30 +07:00
|
|
|
struct vb2_v4l2_buffer vb;
|
2013-03-11 16:52:27 +07:00
|
|
|
struct list_head list;
|
2008-02-16 07:53:09 +07:00
|
|
|
unsigned int frame_offset;
|
|
|
|
u32 modet_active;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GO7007_RATIO_1_1 0
|
|
|
|
#define GO7007_RATIO_4_3 1
|
|
|
|
#define GO7007_RATIO_16_9 2
|
|
|
|
|
|
|
|
enum go7007_parser_state {
|
|
|
|
STATE_DATA,
|
|
|
|
STATE_00,
|
|
|
|
STATE_00_00,
|
|
|
|
STATE_00_00_01,
|
|
|
|
STATE_FF,
|
|
|
|
STATE_VBI_LEN_A,
|
|
|
|
STATE_VBI_LEN_B,
|
|
|
|
STATE_MODET_MAP,
|
|
|
|
STATE_UNPARSED,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct go7007 {
|
|
|
|
struct device *dev;
|
2013-03-09 19:38:03 +07:00
|
|
|
u8 bus_info[32];
|
2013-03-17 20:56:20 +07:00
|
|
|
const struct go7007_board_info *board_info;
|
2008-02-16 07:53:09 +07:00
|
|
|
unsigned int board_id;
|
|
|
|
int tuner_type;
|
|
|
|
int channel_number; /* for multi-channel boards like Adlink PCI-MPG24 */
|
|
|
|
char name[64];
|
2013-03-11 16:34:22 +07:00
|
|
|
struct video_device vdev;
|
2013-03-09 20:37:52 +07:00
|
|
|
void *boot_fw;
|
|
|
|
unsigned boot_fw_len;
|
2009-11-17 01:07:42 +07:00
|
|
|
struct v4l2_device v4l2_dev;
|
2013-03-11 15:19:59 +07:00
|
|
|
struct v4l2_ctrl_handler hdl;
|
2013-03-11 15:58:55 +07:00
|
|
|
struct v4l2_ctrl *mpeg_video_encoding;
|
|
|
|
struct v4l2_ctrl *mpeg_video_gop_size;
|
|
|
|
struct v4l2_ctrl *mpeg_video_gop_closure;
|
|
|
|
struct v4l2_ctrl *mpeg_video_bitrate;
|
|
|
|
struct v4l2_ctrl *mpeg_video_aspect_ratio;
|
2013-03-17 17:16:37 +07:00
|
|
|
struct v4l2_ctrl *mpeg_video_b_frames;
|
2013-03-17 20:47:02 +07:00
|
|
|
struct v4l2_ctrl *mpeg_video_rep_seqheader;
|
2014-06-10 17:39:04 +07:00
|
|
|
struct v4l2_ctrl *modet_mode;
|
2008-02-16 07:53:09 +07:00
|
|
|
enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status;
|
|
|
|
spinlock_t spinlock;
|
2009-09-15 21:07:59 +07:00
|
|
|
struct mutex hw_lock;
|
2013-03-11 16:52:27 +07:00
|
|
|
struct mutex serialize_lock;
|
2008-02-16 07:53:09 +07:00
|
|
|
int audio_enabled;
|
2013-03-09 19:25:47 +07:00
|
|
|
struct v4l2_subdev *sd_video;
|
|
|
|
struct v4l2_subdev *sd_audio;
|
2013-03-09 19:59:16 +07:00
|
|
|
u8 usb_buf[16];
|
2008-02-16 07:53:09 +07:00
|
|
|
|
|
|
|
/* Video input */
|
|
|
|
int input;
|
2013-03-09 19:25:47 +07:00
|
|
|
int aud_input;
|
2008-02-16 07:53:09 +07:00
|
|
|
enum { GO7007_STD_NTSC, GO7007_STD_PAL, GO7007_STD_OTHER } standard;
|
2013-03-11 15:50:21 +07:00
|
|
|
v4l2_std_id std;
|
2008-02-16 07:53:09 +07:00
|
|
|
int sensor_framerate;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int encoder_h_offset;
|
|
|
|
int encoder_v_offset;
|
|
|
|
unsigned int encoder_h_halve:1;
|
|
|
|
unsigned int encoder_v_halve:1;
|
|
|
|
unsigned int encoder_subsample:1;
|
|
|
|
|
|
|
|
/* Encoder config */
|
2013-03-11 15:58:55 +07:00
|
|
|
u32 format;
|
2008-02-16 07:53:09 +07:00
|
|
|
int bitrate;
|
|
|
|
int fps_scale;
|
|
|
|
int pali;
|
|
|
|
int aspect_ratio;
|
|
|
|
int gop_size;
|
|
|
|
unsigned int ipb:1;
|
|
|
|
unsigned int closed_gop:1;
|
|
|
|
unsigned int repeat_seqhead:1;
|
|
|
|
unsigned int seq_header_enable:1;
|
|
|
|
unsigned int gop_header_enable:1;
|
|
|
|
unsigned int dvd_mode:1;
|
|
|
|
unsigned int interlace_coding:1;
|
|
|
|
|
|
|
|
/* Motion detection */
|
|
|
|
unsigned int modet_enable:1;
|
|
|
|
struct {
|
|
|
|
unsigned int enable:1;
|
|
|
|
int pixel_threshold;
|
|
|
|
int motion_threshold;
|
|
|
|
int mb_threshold;
|
|
|
|
} modet[4];
|
|
|
|
unsigned char modet_map[1624];
|
|
|
|
unsigned char active_map[216];
|
2014-06-10 17:39:04 +07:00
|
|
|
u32 modet_event_status;
|
2008-02-16 07:53:09 +07:00
|
|
|
|
|
|
|
/* Video streaming */
|
2013-03-11 16:52:27 +07:00
|
|
|
struct mutex queue_lock;
|
|
|
|
struct vb2_queue vidq;
|
2008-02-16 07:53:09 +07:00
|
|
|
enum go7007_parser_state state;
|
|
|
|
int parse_length;
|
|
|
|
u16 modet_word;
|
|
|
|
int seen_frame;
|
|
|
|
u32 next_seq;
|
2013-03-11 16:52:27 +07:00
|
|
|
struct list_head vidq_active;
|
2008-02-16 07:53:09 +07:00
|
|
|
wait_queue_head_t frame_waitq;
|
2013-03-11 16:52:27 +07:00
|
|
|
struct go7007_buffer *active_buf;
|
2008-02-16 07:53:09 +07:00
|
|
|
|
|
|
|
/* Audio streaming */
|
|
|
|
void (*audio_deliver)(struct go7007 *go, u8 *buf, int length);
|
|
|
|
void *snd_context;
|
|
|
|
|
|
|
|
/* I2C */
|
|
|
|
int i2c_adapter_online;
|
|
|
|
struct i2c_adapter i2c_adapter;
|
|
|
|
|
|
|
|
/* HPI driver */
|
2015-12-11 23:16:48 +07:00
|
|
|
const struct go7007_hpi_ops *hpi_ops;
|
2008-02-16 07:53:09 +07:00
|
|
|
void *hpi_context;
|
|
|
|
int interrupt_available;
|
|
|
|
wait_queue_head_t interrupt_waitq;
|
|
|
|
unsigned short interrupt_value;
|
|
|
|
unsigned short interrupt_data;
|
|
|
|
};
|
|
|
|
|
2009-11-17 01:07:42 +07:00
|
|
|
static inline struct go7007 *to_go7007(struct v4l2_device *v4l2_dev)
|
|
|
|
{
|
|
|
|
return container_of(v4l2_dev, struct go7007, v4l2_dev);
|
|
|
|
}
|
|
|
|
|
2009-09-15 21:07:59 +07:00
|
|
|
/* All of these must be called with the hpi_lock mutex held! */
|
2008-02-16 07:53:09 +07:00
|
|
|
#define go7007_interface_reset(go) \
|
|
|
|
((go)->hpi_ops->interface_reset(go))
|
|
|
|
#define go7007_write_interrupt(go, x, y) \
|
|
|
|
((go)->hpi_ops->write_interrupt)((go), (x), (y))
|
|
|
|
#define go7007_stream_start(go) \
|
|
|
|
((go)->hpi_ops->stream_start(go))
|
|
|
|
#define go7007_stream_stop(go) \
|
|
|
|
((go)->hpi_ops->stream_stop(go))
|
|
|
|
#define go7007_send_firmware(go, x, y) \
|
|
|
|
((go)->hpi_ops->send_firmware)((go), (x), (y))
|
|
|
|
#define go7007_write_addr(go, x, y) \
|
|
|
|
((go)->hpi_ops->write_interrupt)((go), (x)|0x8000, (y))
|
|
|
|
|
|
|
|
/* go7007-driver.c */
|
|
|
|
int go7007_read_addr(struct go7007 *go, u16 addr, u16 *data);
|
|
|
|
int go7007_read_interrupt(struct go7007 *go, u16 *value, u16 *data);
|
|
|
|
int go7007_boot_encoder(struct go7007 *go, int init_i2c);
|
|
|
|
int go7007_reset_encoder(struct go7007 *go);
|
2013-03-09 19:25:47 +07:00
|
|
|
int go7007_register_encoder(struct go7007 *go, unsigned num_i2c_devs);
|
2008-02-16 07:53:09 +07:00
|
|
|
int go7007_start_encoder(struct go7007 *go);
|
|
|
|
void go7007_parse_video_stream(struct go7007 *go, u8 *buf, int length);
|
2013-03-17 20:56:20 +07:00
|
|
|
struct go7007 *go7007_alloc(const struct go7007_board_info *board,
|
2008-02-16 07:53:09 +07:00
|
|
|
struct device *dev);
|
2013-03-11 15:50:21 +07:00
|
|
|
void go7007_update_board(struct go7007 *go);
|
|
|
|
|
2008-02-16 07:53:09 +07:00
|
|
|
/* go7007-fw.c */
|
|
|
|
int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen);
|
|
|
|
|
|
|
|
/* go7007-i2c.c */
|
|
|
|
int go7007_i2c_init(struct go7007 *go);
|
|
|
|
int go7007_i2c_remove(struct go7007 *go);
|
|
|
|
|
|
|
|
/* go7007-v4l2.c */
|
|
|
|
int go7007_v4l2_init(struct go7007 *go);
|
2013-03-11 15:19:59 +07:00
|
|
|
int go7007_v4l2_ctrl_init(struct go7007 *go);
|
2008-02-16 07:53:09 +07:00
|
|
|
void go7007_v4l2_remove(struct go7007 *go);
|
|
|
|
|
|
|
|
/* snd-go7007.c */
|
|
|
|
int go7007_snd_init(struct go7007 *go);
|
|
|
|
int go7007_snd_remove(struct go7007 *go);
|