2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-25 05:34:00 +08:00

media: cxusb: add analog mode support for Medion MD95700

This patch adds support for analog part of Medion 95700 in the cxusb
driver.

What works:
* Video capture at various sizes with sequential fields,
* Input switching (TV Tuner, Composite, S-Video),
* TV and radio tuning,
* Video standard switching and auto detection,
* Radio mode switching (stereo / mono),
* Unplugging while capturing,
* DVB / analog coexistence.

What does not work yet:
* Audio,
* VBI,
* Picture controls.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[hverkuil-cisco@xs4all.nl: remove left-over commented-out debug message]
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Maciej S. Szmigiero 2019-04-29 12:16:58 -04:00 committed by Mauro Carvalho Chehab
parent d525e5c2f1
commit e478d40540
5 changed files with 1968 additions and 4 deletions

View File

@ -139,12 +139,24 @@ config DVB_USB_CXUSB
select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT
help
Say Y here to support the Conexant USB2.0 hybrid reference design.
Currently, only DVB and ATSC modes are supported, analog mode
shall be added in the future. Devices that require this module:
DVB and ATSC modes are supported, for a basic analog mode support
see the next option ("Analog support for the Conexant USB2.0 hybrid
reference design").
Devices that require this module:
Medion MD95700 hybrid USB2.0 device.
DViCO FusionHDTV (Bluebird) USB2.0 devices
config DVB_USB_CXUSB_ANALOG
bool "Analog support for the Conexant USB2.0 hybrid reference design"
depends on DVB_USB_CXUSB && VIDEO_V4L2
select VIDEO_CX25840
select VIDEOBUF2_VMALLOC
help
Say Y here to enable basic analog mode support for the Conexant
USB2.0 hybrid reference design.
Currently this mode is supported only on a Medion MD95700 device.
config DVB_USB_M920X
tristate "Uli m920x DVB-T USB2.0 support"
depends on DVB_USB

View File

@ -42,6 +42,9 @@ dvb-usb-digitv-objs := digitv.o
obj-$(CONFIG_DVB_USB_DIGITV) += dvb-usb-digitv.o
dvb-usb-cxusb-objs := cxusb.o
ifeq ($(CONFIG_DVB_USB_CXUSB_ANALOG),y)
dvb-usb-cxusb-objs += cxusb-analog.o
endif
obj-$(CONFIG_DVB_USB_CXUSB) += dvb-usb-cxusb.o
dvb-usb-ttusb2-objs := ttusb2.o

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,6 @@
* design, so it can be reused for the "analogue-only" device (if it will
* appear at all).
*
* TODO: Use the cx25840-driver for the analogue part
*
* Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
* Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
@ -2548,5 +2547,4 @@ MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
MODULE_AUTHOR("Maciej S. Szmigiero <mail@maciej.szmigiero.name>");
MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
MODULE_VERSION("1.0-alpha");
MODULE_LICENSE("GPL");

View File

@ -2,12 +2,29 @@
#ifndef _DVB_USB_CXUSB_H_
#define _DVB_USB_CXUSB_H_
#include <linux/completion.h>
#include <linux/i2c.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/usb.h>
#include <linux/workqueue.h>
#include <media/v4l2-common.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>
#include <media/videobuf2-core.h>
#include <media/videobuf2-v4l2.h>
#define DVB_USB_LOG_PREFIX "cxusb"
#include "dvb-usb.h"
#define CXUSB_VIDEO_URBS (5)
#define CXUSB_VIDEO_URB_MAX_SIZE (512 * 1024)
#define CXUSB_VIDEO_PKT_SIZE 3030
#define CXUSB_VIDEO_MAX_FRAME_PKTS 346
#define CXUSB_VIDEO_MAX_FRAME_SIZE (CXUSB_VIDEO_MAX_FRAME_PKTS * \
CXUSB_VIDEO_PKT_SIZE)
/* usb commands - some of it are guesses, don't have a reference yet */
#define CMD_BLUEBIRD_GPIO_RW 0x05
@ -32,6 +49,20 @@
#define CMD_ANALOG 0x50
#define CMD_DIGITAL 0x51
#define CXUSB_BT656_PREAMBLE ((const u8 *)"\xff\x00\x00")
#define CXUSB_BT656_FIELD_MASK BIT(6)
#define CXUSB_BT656_FIELD_1 0
#define CXUSB_BT656_FIELD_2 BIT(6)
#define CXUSB_BT656_VBI_MASK BIT(5)
#define CXUSB_BT656_VBI_ON BIT(5)
#define CXUSB_BT656_VBI_OFF 0
#define CXUSB_BT656_SEAV_MASK BIT(4)
#define CXUSB_BT656_SEAV_EAV BIT(4)
#define CXUSB_BT656_SEAV_SAV 0
/* Max transfer size done by I2C transfer functions */
#define MAX_XFER_SIZE 80
@ -54,6 +85,29 @@ enum cxusb_open_type {
CXUSB_OPEN_ANALOG, CXUSB_OPEN_DIGITAL
};
struct cxusb_medion_auxbuf {
u8 *buf;
unsigned int len;
unsigned int paylen;
};
enum cxusb_bt656_mode {
NEW_FRAME, FIRST_FIELD, SECOND_FIELD
};
enum cxusb_bt656_fmode {
START_SEARCH, LINE_SAMPLES, VBI_SAMPLES
};
struct cxusb_bt656_params {
enum cxusb_bt656_mode mode;
enum cxusb_bt656_fmode fmode;
unsigned int pos;
unsigned int line;
unsigned int linesamples;
u8 *buf;
};
struct cxusb_medion_dev {
/* has to be the first one */
struct cxusb_state state;
@ -63,18 +117,69 @@ struct cxusb_medion_dev {
enum cxusb_open_type open_type;
unsigned int open_ctr;
struct mutex open_lock;
#ifdef CONFIG_DVB_USB_CXUSB_ANALOG
struct v4l2_device v4l2dev;
struct v4l2_subdev *cx25840;
struct v4l2_subdev *tuner;
struct v4l2_subdev *tda9887;
struct video_device *videodev, *radiodev;
struct mutex dev_lock;
struct vb2_queue videoqueue;
u32 input;
bool stop_streaming;
u32 width, height;
u32 field_order;
struct cxusb_medion_auxbuf auxbuf;
v4l2_std_id norm;
struct urb *streamurbs[CXUSB_VIDEO_URBS];
unsigned long urbcomplete;
struct work_struct urbwork;
unsigned int nexturb;
struct cxusb_bt656_params bt656;
struct cxusb_medion_vbuffer *vbuf;
__u32 vbuf_sequence;
struct list_head buflist;
struct completion v4l2_release;
#endif
};
struct cxusb_medion_vbuffer {
struct vb2_v4l2_buffer vb2;
struct list_head list;
};
/* defines for "debug" module parameter */
#define CXUSB_DBG_RC BIT(0)
#define CXUSB_DBG_I2C BIT(1)
#define CXUSB_DBG_MISC BIT(2)
#define CXUSB_DBG_BT656 BIT(3)
#define CXUSB_DBG_URB BIT(4)
#define CXUSB_DBG_OPS BIT(5)
#define CXUSB_DBG_AUXB BIT(6)
extern int dvb_usb_cxusb_debug;
#define cxusb_vprintk(dvbdev, lvl, ...) do { \
struct cxusb_medion_dev *_cxdev = (dvbdev)->priv; \
if (dvb_usb_cxusb_debug & CXUSB_DBG_##lvl) \
v4l2_printk(KERN_DEBUG, \
&_cxdev->v4l2dev, __VA_ARGS__); \
} while (0)
int cxusb_ctrl_msg(struct dvb_usb_device *d,
u8 cmd, const u8 *wbuf, int wlen, u8 *rbuf, int rlen);
#ifdef CONFIG_DVB_USB_CXUSB_ANALOG
int cxusb_medion_analog_init(struct dvb_usb_device *dvbdev);
int cxusb_medion_register_analog(struct dvb_usb_device *dvbdev);
void cxusb_medion_unregister_analog(struct dvb_usb_device *dvbdev);
#else
static inline int cxusb_medion_analog_init(struct dvb_usb_device *dvbdev)
{
return -EINVAL;
@ -88,6 +193,7 @@ static inline int cxusb_medion_register_analog(struct dvb_usb_device *dvbdev)
static inline void cxusb_medion_unregister_analog(struct dvb_usb_device *dvbdev)
{
}
#endif
int cxusb_medion_get(struct dvb_usb_device *dvbdev,
enum cxusb_open_type open_type);