2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
/*
|
|
|
|
ioctl control functions
|
|
|
|
Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
|
|
|
|
Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ivtv-driver.h"
|
|
|
|
#include "ivtv-ioctl.h"
|
|
|
|
#include "ivtv-controls.h"
|
2011-12-15 21:32:53 +08:00
|
|
|
#include "ivtv-mailbox.h"
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
2010-06-27 17:07:26 +08:00
|
|
|
static int ivtv_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
{
|
2010-06-27 17:07:26 +08:00
|
|
|
struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
|
|
|
/* First try to allocate sliced VBI buffers if needed. */
|
|
|
|
if (fmt && itv->vbi.sliced_mpeg_data[0] == NULL) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < IVTV_VBI_FRAMES; i++) {
|
|
|
|
/* Yuck, hardcoded. Needs to be a define */
|
|
|
|
itv->vbi.sliced_mpeg_data[i] = kmalloc(2049, GFP_KERNEL);
|
|
|
|
if (itv->vbi.sliced_mpeg_data[i] == NULL) {
|
|
|
|
while (--i >= 0) {
|
|
|
|
kfree(itv->vbi.sliced_mpeg_data[i]);
|
|
|
|
itv->vbi.sliced_mpeg_data[i] = NULL;
|
|
|
|
}
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
itv->vbi.insert_mpeg = fmt;
|
|
|
|
|
|
|
|
if (itv->vbi.insert_mpeg == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* Need sliced data for mpeg insertion */
|
2008-05-01 20:22:13 +08:00
|
|
|
if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) {
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
if (itv->is_60hz)
|
|
|
|
itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525;
|
|
|
|
else
|
|
|
|
itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625;
|
2008-05-01 20:22:13 +08:00
|
|
|
ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz);
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-27 17:07:26 +08:00
|
|
|
static int ivtv_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val)
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
{
|
2010-06-27 17:07:26 +08:00
|
|
|
struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
|
|
|
|
int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
|
2015-04-09 15:05:59 +08:00
|
|
|
struct v4l2_subdev_format format = {
|
|
|
|
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
|
|
|
|
};
|
2010-06-27 17:07:26 +08:00
|
|
|
|
|
|
|
/* fix videodecoder resolution */
|
2015-04-09 15:05:59 +08:00
|
|
|
format.format.width = cxhdl->width / (is_mpeg1 ? 2 : 1);
|
|
|
|
format.format.height = cxhdl->height;
|
|
|
|
format.format.code = MEDIA_BUS_FMT_FIXED;
|
|
|
|
v4l2_subdev_call(itv->sd_video, pad, set_fmt, NULL, &format);
|
2010-06-27 17:07:26 +08:00
|
|
|
return 0;
|
2008-05-30 03:43:54 +08:00
|
|
|
}
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
2010-06-27 17:07:26 +08:00
|
|
|
static int ivtv_s_audio_sampling_freq(struct cx2341x_handler *cxhdl, u32 idx)
|
2008-05-30 03:43:54 +08:00
|
|
|
{
|
2010-06-27 17:07:26 +08:00
|
|
|
static const u32 freqs[3] = { 44100, 48000, 32000 };
|
|
|
|
struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
2010-06-27 17:07:26 +08:00
|
|
|
/* The audio clock of the digitizer must match the codec sample
|
|
|
|
rate otherwise you get some very strange effects. */
|
|
|
|
if (idx < ARRAY_SIZE(freqs))
|
|
|
|
ivtv_call_all(itv, audio, s_clock_freq, freqs[idx]);
|
|
|
|
return 0;
|
2008-05-30 03:43:54 +08:00
|
|
|
}
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
|
2010-06-27 17:07:26 +08:00
|
|
|
static int ivtv_s_audio_mode(struct cx2341x_handler *cxhdl, u32 val)
|
2008-05-30 03:43:54 +08:00
|
|
|
{
|
2010-06-27 17:07:26 +08:00
|
|
|
struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);
|
2008-05-30 03:43:54 +08:00
|
|
|
|
2010-06-27 17:07:26 +08:00
|
|
|
itv->dualwatch_stereo_mode = val;
|
|
|
|
return 0;
|
V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder
It took three core maintainers, over four years of work, eight new i2c
modules, eleven new V4L2 ioctls, three new DVB video ioctls, a Sliced
VBI API, a new MPEG encoder API, an enhanced DVB video MPEG decoding
API, major YUV/OSD contributions from Ian and John, web/wiki/svn/trac
support from Axel Thimm, (hardware) support from Hauppauge, support and
assistance from the v4l-dvb people and the many, many users of ivtv to
finally make it possible to merge this driver into the kernel.
Thank you all!
Signed-off-by: Kevin Thayer <nufan_wfk@yahoo.com>
Signed-off-by: Chris Kennedy <c@groovy.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: John P Harvey <john.p.harvey@btinternet.com>
Signed-off-by: Ian Armstrong <ian@iarmst.demon.co.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
2007-04-27 23:31:25 +08:00
|
|
|
}
|
2010-06-27 17:07:26 +08:00
|
|
|
|
2015-11-23 01:44:38 +08:00
|
|
|
const struct cx2341x_handler_ops ivtv_cxhdl_ops = {
|
2010-06-27 17:07:26 +08:00
|
|
|
.s_audio_mode = ivtv_s_audio_mode,
|
|
|
|
.s_audio_sampling_freq = ivtv_s_audio_sampling_freq,
|
|
|
|
.s_video_encoding = ivtv_s_video_encoding,
|
|
|
|
.s_stream_vbi_fmt = ivtv_s_stream_vbi_fmt,
|
|
|
|
};
|
2011-12-15 21:32:53 +08:00
|
|
|
|
|
|
|
int ivtv_g_pts_frame(struct ivtv *itv, s64 *pts, s64 *frame)
|
|
|
|
{
|
|
|
|
u32 data[CX2341X_MBOX_MAX_DATA];
|
|
|
|
|
|
|
|
if (test_bit(IVTV_F_I_VALID_DEC_TIMINGS, &itv->i_flags)) {
|
|
|
|
*pts = (s64)((u64)itv->last_dec_timing[2] << 32) |
|
|
|
|
(u64)itv->last_dec_timing[1];
|
|
|
|
*frame = itv->last_dec_timing[0];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
*pts = 0;
|
|
|
|
*frame = 0;
|
|
|
|
if (atomic_read(&itv->decoding)) {
|
|
|
|
if (ivtv_api(itv, CX2341X_DEC_GET_TIMING_INFO, 5, data)) {
|
|
|
|
IVTV_DEBUG_WARN("GET_TIMING: couldn't read clock\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
memcpy(itv->last_dec_timing, data, sizeof(itv->last_dec_timing));
|
|
|
|
set_bit(IVTV_F_I_VALID_DEC_TIMINGS, &itv->i_flags);
|
|
|
|
*pts = (s64)((u64) data[2] << 32) | (u64) data[1];
|
|
|
|
*frame = data[0];
|
|
|
|
/*timing->scr = (u64) (((u64) data[4] << 32) | (u64) (data[3]));*/
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ivtv_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
|
|
|
|
{
|
2012-03-03 00:02:11 +08:00
|
|
|
struct ivtv *itv = container_of(ctrl->handler, struct ivtv, cxhdl.hdl);
|
2011-12-15 21:32:53 +08:00
|
|
|
|
|
|
|
switch (ctrl->id) {
|
|
|
|
/* V4L2_CID_MPEG_VIDEO_DEC_PTS and V4L2_CID_MPEG_VIDEO_DEC_FRAME
|
|
|
|
control cluster */
|
|
|
|
case V4L2_CID_MPEG_VIDEO_DEC_PTS:
|
2014-04-27 14:38:13 +08:00
|
|
|
return ivtv_g_pts_frame(itv, itv->ctrl_pts->p_new.p_s64,
|
|
|
|
itv->ctrl_frame->p_new.p_s64);
|
2011-12-15 21:32:53 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ivtv_s_ctrl(struct v4l2_ctrl *ctrl)
|
|
|
|
{
|
2012-03-03 00:02:11 +08:00
|
|
|
struct ivtv *itv = container_of(ctrl->handler, struct ivtv, cxhdl.hdl);
|
2011-12-15 21:32:53 +08:00
|
|
|
|
|
|
|
switch (ctrl->id) {
|
|
|
|
/* V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK and MULTILINGUAL_PLAYBACK
|
|
|
|
control cluster */
|
|
|
|
case V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK:
|
|
|
|
itv->audio_stereo_mode = itv->ctrl_audio_playback->val - 1;
|
|
|
|
itv->audio_bilingual_mode = itv->ctrl_audio_multilingual_playback->val - 1;
|
|
|
|
ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct v4l2_ctrl_ops ivtv_hdl_out_ops = {
|
|
|
|
.s_ctrl = ivtv_s_ctrl,
|
|
|
|
.g_volatile_ctrl = ivtv_g_volatile_ctrl,
|
|
|
|
};
|