2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* device driver for philips saa7134 based TV cards
|
|
|
|
* video4linux video interface
|
|
|
|
*
|
|
|
|
* (c) 2001-03 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2015-04-30 16:44:56 +07:00
|
|
|
#include "saa7134.h"
|
|
|
|
#include "saa7134-reg.h"
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
2007-04-27 22:31:18 +07:00
|
|
|
#include <linux/sort.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-01-10 00:32:31 +07:00
|
|
|
#include <media/v4l2-common.h>
|
2013-12-14 18:28:28 +07:00
|
|
|
#include <media/v4l2-event.h>
|
2015-11-10 21:01:44 +07:00
|
|
|
#include <media/i2c/saa6588.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
unsigned int video_debug;
|
2005-04-17 05:20:36 +07:00
|
|
|
static unsigned int gbuffers = 8;
|
2008-04-23 00:41:48 +07:00
|
|
|
static unsigned int noninterlaced; /* 0 */
|
2005-04-17 05:20:36 +07:00
|
|
|
static unsigned int gbufsize = 720*576*4;
|
|
|
|
static unsigned int gbufsize_max = 720*576*4;
|
2006-10-03 05:55:07 +07:00
|
|
|
static char secam[] = "--";
|
2005-04-17 05:20:36 +07:00
|
|
|
module_param(video_debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
|
|
|
|
module_param(gbuffers, int, 0444);
|
|
|
|
MODULE_PARM_DESC(gbuffers,"number of capture buffers, range 2-32");
|
|
|
|
module_param(noninterlaced, int, 0644);
|
2006-07-15 19:45:34 +07:00
|
|
|
MODULE_PARM_DESC(noninterlaced,"capture non interlaced video");
|
2006-10-03 05:55:07 +07:00
|
|
|
module_param_string(secam, secam, sizeof(secam), 0644);
|
|
|
|
MODULE_PARM_DESC(secam, "force SECAM variant, either DK,L or Lc");
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-05-14 00:09:25 +07:00
|
|
|
#define video_dbg(fmt, arg...) do { \
|
|
|
|
if (video_debug & 0x04) \
|
|
|
|
printk(KERN_DEBUG pr_fmt("video: " fmt), ## arg); \
|
|
|
|
} while (0)
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-11-09 12:37:10 +07:00
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
/* Defines for Video Output Port Register at address 0x191 */
|
|
|
|
|
|
|
|
/* Bit 0: VIP code T bit polarity */
|
|
|
|
|
|
|
|
#define VP_T_CODE_P_NON_INVERTED 0x00
|
|
|
|
#define VP_T_CODE_P_INVERTED 0x01
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
/* Defines for Video Output Port Register at address 0x195 */
|
|
|
|
|
|
|
|
/* Bit 2: Video output clock delay control */
|
|
|
|
|
|
|
|
#define VP_CLK_CTRL2_NOT_DELAYED 0x00
|
|
|
|
#define VP_CLK_CTRL2_DELAYED 0x04
|
|
|
|
|
|
|
|
/* Bit 1: Video output clock invert control */
|
|
|
|
|
|
|
|
#define VP_CLK_CTRL1_NON_INVERTED 0x00
|
|
|
|
#define VP_CLK_CTRL1_INVERTED 0x02
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
/* Defines for Video Output Port Register at address 0x196 */
|
|
|
|
|
|
|
|
/* Bits 2 to 0: VSYNC pin video vertical sync type */
|
|
|
|
|
|
|
|
#define VP_VS_TYPE_MASK 0x07
|
|
|
|
|
|
|
|
#define VP_VS_TYPE_OFF 0x00
|
|
|
|
#define VP_VS_TYPE_V123 0x01
|
|
|
|
#define VP_VS_TYPE_V_ITU 0x02
|
|
|
|
#define VP_VS_TYPE_VGATE_L 0x03
|
|
|
|
#define VP_VS_TYPE_RESERVED1 0x04
|
|
|
|
#define VP_VS_TYPE_RESERVED2 0x05
|
|
|
|
#define VP_VS_TYPE_F_ITU 0x06
|
|
|
|
#define VP_VS_TYPE_SC_FID 0x07
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
/* data structs for video */
|
|
|
|
|
|
|
|
static int video_out[][9] = {
|
|
|
|
[CCIR656] = { 0x00, 0xb1, 0x00, 0xa1, 0x00, 0x04, 0x06, 0x00, 0x00 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct saa7134_format formats[] = {
|
|
|
|
{
|
|
|
|
.name = "8 bpp gray",
|
|
|
|
.fourcc = V4L2_PIX_FMT_GREY,
|
|
|
|
.depth = 8,
|
|
|
|
.pm = 0x06,
|
|
|
|
},{
|
|
|
|
.name = "15 bpp RGB, le",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB555,
|
|
|
|
.depth = 16,
|
|
|
|
.pm = 0x13 | 0x80,
|
|
|
|
},{
|
|
|
|
.name = "15 bpp RGB, be",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB555X,
|
|
|
|
.depth = 16,
|
|
|
|
.pm = 0x13 | 0x80,
|
|
|
|
.bswap = 1,
|
|
|
|
},{
|
|
|
|
.name = "16 bpp RGB, le",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB565,
|
|
|
|
.depth = 16,
|
|
|
|
.pm = 0x10 | 0x80,
|
|
|
|
},{
|
|
|
|
.name = "16 bpp RGB, be",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB565X,
|
|
|
|
.depth = 16,
|
|
|
|
.pm = 0x10 | 0x80,
|
|
|
|
.bswap = 1,
|
|
|
|
},{
|
|
|
|
.name = "24 bpp RGB, le",
|
|
|
|
.fourcc = V4L2_PIX_FMT_BGR24,
|
|
|
|
.depth = 24,
|
|
|
|
.pm = 0x11,
|
|
|
|
},{
|
|
|
|
.name = "24 bpp RGB, be",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB24,
|
|
|
|
.depth = 24,
|
|
|
|
.pm = 0x11,
|
|
|
|
.bswap = 1,
|
|
|
|
},{
|
|
|
|
.name = "32 bpp RGB, le",
|
|
|
|
.fourcc = V4L2_PIX_FMT_BGR32,
|
|
|
|
.depth = 32,
|
|
|
|
.pm = 0x12,
|
|
|
|
},{
|
|
|
|
.name = "32 bpp RGB, be",
|
|
|
|
.fourcc = V4L2_PIX_FMT_RGB32,
|
|
|
|
.depth = 32,
|
|
|
|
.pm = 0x12,
|
|
|
|
.bswap = 1,
|
|
|
|
.wswap = 1,
|
|
|
|
},{
|
|
|
|
.name = "4:2:2 packed, YUYV",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YUYV,
|
|
|
|
.depth = 16,
|
|
|
|
.pm = 0x00,
|
|
|
|
.bswap = 1,
|
|
|
|
.yuv = 1,
|
|
|
|
},{
|
|
|
|
.name = "4:2:2 packed, UYVY",
|
|
|
|
.fourcc = V4L2_PIX_FMT_UYVY,
|
|
|
|
.depth = 16,
|
|
|
|
.pm = 0x00,
|
|
|
|
.yuv = 1,
|
|
|
|
},{
|
|
|
|
.name = "4:2:2 planar, Y-Cb-Cr",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YUV422P,
|
|
|
|
.depth = 16,
|
|
|
|
.pm = 0x09,
|
|
|
|
.yuv = 1,
|
|
|
|
.planar = 1,
|
|
|
|
.hshift = 1,
|
|
|
|
.vshift = 0,
|
|
|
|
},{
|
|
|
|
.name = "4:2:0 planar, Y-Cb-Cr",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YUV420,
|
|
|
|
.depth = 12,
|
|
|
|
.pm = 0x0a,
|
|
|
|
.yuv = 1,
|
|
|
|
.planar = 1,
|
|
|
|
.hshift = 1,
|
|
|
|
.vshift = 1,
|
|
|
|
},{
|
|
|
|
.name = "4:2:0 planar, Y-Cb-Cr",
|
|
|
|
.fourcc = V4L2_PIX_FMT_YVU420,
|
|
|
|
.depth = 12,
|
|
|
|
.pm = 0x0a,
|
|
|
|
.yuv = 1,
|
|
|
|
.planar = 1,
|
|
|
|
.uvswap = 1,
|
|
|
|
.hshift = 1,
|
|
|
|
.vshift = 1,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#define FORMATS ARRAY_SIZE(formats)
|
|
|
|
|
|
|
|
#define NORM_625_50 \
|
|
|
|
.h_start = 0, \
|
|
|
|
.h_stop = 719, \
|
|
|
|
.video_v_start = 24, \
|
|
|
|
.video_v_stop = 311, \
|
2005-06-24 12:04:47 +07:00
|
|
|
.vbi_v_start_0 = 7, \
|
2014-09-21 16:38:55 +07:00
|
|
|
.vbi_v_stop_0 = 23, \
|
2005-06-24 12:04:47 +07:00
|
|
|
.vbi_v_start_1 = 319, \
|
2005-04-17 05:20:36 +07:00
|
|
|
.src_timing = 4
|
|
|
|
|
|
|
|
#define NORM_525_60 \
|
|
|
|
.h_start = 0, \
|
2010-02-06 20:58:41 +07:00
|
|
|
.h_stop = 719, \
|
2005-06-24 12:04:47 +07:00
|
|
|
.video_v_start = 23, \
|
|
|
|
.video_v_stop = 262, \
|
|
|
|
.vbi_v_start_0 = 10, \
|
|
|
|
.vbi_v_stop_0 = 21, \
|
|
|
|
.vbi_v_start_1 = 273, \
|
|
|
|
.src_timing = 7
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
static struct saa7134_tvnorm tvnorms[] = {
|
|
|
|
{
|
|
|
|
.name = "PAL", /* autodetect */
|
|
|
|
.id = V4L2_STD_PAL,
|
|
|
|
NORM_625_50,
|
|
|
|
|
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x40,
|
|
|
|
.chroma_ctrl1 = 0x81,
|
|
|
|
.chroma_gain = 0x2a,
|
|
|
|
.chroma_ctrl2 = 0x06,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "PAL-BG",
|
|
|
|
.id = V4L2_STD_PAL_BG,
|
|
|
|
NORM_625_50,
|
|
|
|
|
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x40,
|
|
|
|
.chroma_ctrl1 = 0x81,
|
|
|
|
.chroma_gain = 0x2a,
|
|
|
|
.chroma_ctrl2 = 0x06,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "PAL-I",
|
|
|
|
.id = V4L2_STD_PAL_I,
|
|
|
|
NORM_625_50,
|
|
|
|
|
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x40,
|
|
|
|
.chroma_ctrl1 = 0x81,
|
|
|
|
.chroma_gain = 0x2a,
|
|
|
|
.chroma_ctrl2 = 0x06,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "PAL-DK",
|
|
|
|
.id = V4L2_STD_PAL_DK,
|
|
|
|
NORM_625_50,
|
|
|
|
|
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x40,
|
|
|
|
.chroma_ctrl1 = 0x81,
|
|
|
|
.chroma_gain = 0x2a,
|
|
|
|
.chroma_ctrl2 = 0x06,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "NTSC",
|
|
|
|
.id = V4L2_STD_NTSC,
|
|
|
|
NORM_525_60,
|
|
|
|
|
|
|
|
.sync_control = 0x59,
|
|
|
|
.luma_control = 0x40,
|
|
|
|
.chroma_ctrl1 = 0x89,
|
|
|
|
.chroma_gain = 0x2a,
|
|
|
|
.chroma_ctrl2 = 0x0e,
|
|
|
|
.vgate_misc = 0x18,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "SECAM",
|
|
|
|
.id = V4L2_STD_SECAM,
|
|
|
|
NORM_625_50,
|
|
|
|
|
2006-10-03 05:55:07 +07:00
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x1b,
|
|
|
|
.chroma_ctrl1 = 0xd1,
|
|
|
|
.chroma_gain = 0x80,
|
|
|
|
.chroma_ctrl2 = 0x00,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "SECAM-DK",
|
|
|
|
.id = V4L2_STD_SECAM_DK,
|
|
|
|
NORM_625_50,
|
|
|
|
|
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x1b,
|
|
|
|
.chroma_ctrl1 = 0xd1,
|
|
|
|
.chroma_gain = 0x80,
|
|
|
|
.chroma_ctrl2 = 0x00,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "SECAM-L",
|
|
|
|
.id = V4L2_STD_SECAM_L,
|
|
|
|
NORM_625_50,
|
|
|
|
|
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x1b,
|
|
|
|
.chroma_ctrl1 = 0xd1,
|
|
|
|
.chroma_gain = 0x80,
|
|
|
|
.chroma_ctrl2 = 0x00,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "SECAM-Lc",
|
|
|
|
.id = V4L2_STD_SECAM_LC,
|
|
|
|
NORM_625_50,
|
|
|
|
|
|
|
|
.sync_control = 0x18,
|
2005-04-17 05:20:36 +07:00
|
|
|
.luma_control = 0x1b,
|
|
|
|
.chroma_ctrl1 = 0xd1,
|
|
|
|
.chroma_gain = 0x80,
|
|
|
|
.chroma_ctrl2 = 0x00,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "PAL-M",
|
|
|
|
.id = V4L2_STD_PAL_M,
|
|
|
|
NORM_525_60,
|
|
|
|
|
|
|
|
.sync_control = 0x59,
|
|
|
|
.luma_control = 0x40,
|
|
|
|
.chroma_ctrl1 = 0xb9,
|
|
|
|
.chroma_gain = 0x2a,
|
|
|
|
.chroma_ctrl2 = 0x0e,
|
|
|
|
.vgate_misc = 0x18,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "PAL-Nc",
|
|
|
|
.id = V4L2_STD_PAL_Nc,
|
|
|
|
NORM_625_50,
|
|
|
|
|
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x40,
|
|
|
|
.chroma_ctrl1 = 0xa1,
|
|
|
|
.chroma_gain = 0x2a,
|
|
|
|
.chroma_ctrl2 = 0x06,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
|
|
|
|
},{
|
|
|
|
.name = "PAL-60",
|
|
|
|
.id = V4L2_STD_PAL_60,
|
|
|
|
|
|
|
|
.h_start = 0,
|
|
|
|
.h_stop = 719,
|
2005-11-09 12:37:43 +07:00
|
|
|
.video_v_start = 23,
|
|
|
|
.video_v_stop = 262,
|
|
|
|
.vbi_v_start_0 = 10,
|
|
|
|
.vbi_v_stop_0 = 21,
|
|
|
|
.vbi_v_start_1 = 273,
|
|
|
|
.src_timing = 7,
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
.sync_control = 0x18,
|
|
|
|
.luma_control = 0x40,
|
|
|
|
.chroma_ctrl1 = 0x81,
|
|
|
|
.chroma_gain = 0x2a,
|
|
|
|
.chroma_ctrl2 = 0x06,
|
|
|
|
.vgate_misc = 0x1c,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#define TVNORMS ARRAY_SIZE(tvnorms)
|
|
|
|
|
|
|
|
static struct saa7134_format* format_by_fourcc(unsigned int fourcc)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < FORMATS; i++)
|
|
|
|
if (formats[i].fourcc == fourcc)
|
|
|
|
return formats+i;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2007-10-24 23:23:14 +07:00
|
|
|
static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2015-05-14 00:09:42 +07:00
|
|
|
video_dbg("set tv norm = %s\n", norm->name);
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->tvnorm = norm;
|
|
|
|
|
|
|
|
/* setup cropping */
|
|
|
|
dev->crop_bounds.left = norm->h_start;
|
|
|
|
dev->crop_defrect.left = norm->h_start;
|
|
|
|
dev->crop_bounds.width = norm->h_stop - norm->h_start +1;
|
|
|
|
dev->crop_defrect.width = norm->h_stop - norm->h_start +1;
|
|
|
|
|
2005-06-24 12:04:47 +07:00
|
|
|
dev->crop_bounds.top = (norm->vbi_v_stop_0+1)*2;
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->crop_defrect.top = norm->video_v_start*2;
|
|
|
|
dev->crop_bounds.height = ((norm->id & V4L2_STD_525_60) ? 524 : 624)
|
|
|
|
- dev->crop_bounds.top;
|
|
|
|
dev->crop_defrect.height = (norm->video_v_stop - norm->video_v_start +1)*2;
|
|
|
|
|
|
|
|
dev->crop_current = dev->crop_defrect;
|
|
|
|
|
2007-10-12 10:57:15 +07:00
|
|
|
saa7134_set_tvnorm_hw(dev);
|
2007-09-28 06:34:25 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void video_mux(struct saa7134_dev *dev, int input)
|
|
|
|
{
|
2016-02-05 19:24:37 +07:00
|
|
|
video_dbg("video input = %d [%s]\n",
|
|
|
|
input, saa7134_input_name[card_in(dev, input).type]);
|
2007-09-28 06:34:25 +07:00
|
|
|
dev->ctl_input = input;
|
|
|
|
set_tvnorm(dev, dev->tvnorm);
|
|
|
|
saa7134_tvaudio_setinput(dev, &card_in(dev, input));
|
|
|
|
}
|
|
|
|
|
2007-10-12 10:57:15 +07:00
|
|
|
|
|
|
|
static void saa7134_set_decoder(struct saa7134_dev *dev)
|
2007-09-28 06:34:25 +07:00
|
|
|
{
|
2014-04-01 19:28:17 +07:00
|
|
|
int luma_control, sync_control, chroma_ctrl1, mux;
|
2007-09-28 06:34:25 +07:00
|
|
|
|
|
|
|
struct saa7134_tvnorm *norm = dev->tvnorm;
|
|
|
|
mux = card_in(dev, dev->ctl_input).vmux;
|
|
|
|
|
|
|
|
luma_control = norm->luma_control;
|
|
|
|
sync_control = norm->sync_control;
|
2014-04-01 19:28:17 +07:00
|
|
|
chroma_ctrl1 = norm->chroma_ctrl1;
|
2007-09-28 06:34:25 +07:00
|
|
|
|
|
|
|
if (mux > 5)
|
|
|
|
luma_control |= 0x80; /* svideo */
|
|
|
|
if (noninterlaced || dev->nosignal)
|
|
|
|
sync_control |= 0x20;
|
|
|
|
|
2014-04-01 19:28:17 +07:00
|
|
|
/* switch on auto standard detection */
|
|
|
|
sync_control |= SAA7134_SYNC_CTRL_AUFD;
|
|
|
|
chroma_ctrl1 |= SAA7134_CHROMA_CTRL1_AUTO0;
|
|
|
|
chroma_ctrl1 &= ~SAA7134_CHROMA_CTRL1_FCTC;
|
|
|
|
luma_control &= ~SAA7134_LUMA_CTRL_LDEL;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* setup video decoder */
|
|
|
|
saa_writeb(SAA7134_INCR_DELAY, 0x08);
|
|
|
|
saa_writeb(SAA7134_ANALOG_IN_CTRL1, 0xc0 | mux);
|
|
|
|
saa_writeb(SAA7134_ANALOG_IN_CTRL2, 0x00);
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_ANALOG_IN_CTRL3, 0x90);
|
|
|
|
saa_writeb(SAA7134_ANALOG_IN_CTRL4, 0x90);
|
|
|
|
saa_writeb(SAA7134_HSYNC_START, 0xeb);
|
|
|
|
saa_writeb(SAA7134_HSYNC_STOP, 0xe0);
|
|
|
|
saa_writeb(SAA7134_SOURCE_TIMING1, norm->src_timing);
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_SYNC_CTRL, sync_control);
|
|
|
|
saa_writeb(SAA7134_LUMA_CTRL, luma_control);
|
|
|
|
saa_writeb(SAA7134_DEC_LUMA_BRIGHT, dev->ctl_bright);
|
|
|
|
|
2007-09-28 06:34:20 +07:00
|
|
|
saa_writeb(SAA7134_DEC_LUMA_CONTRAST,
|
|
|
|
dev->ctl_invert ? -dev->ctl_contrast : dev->ctl_contrast);
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_DEC_CHROMA_SATURATION,
|
|
|
|
dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
saa_writeb(SAA7134_DEC_CHROMA_HUE, dev->ctl_hue);
|
2014-04-01 19:28:17 +07:00
|
|
|
saa_writeb(SAA7134_CHROMA_CTRL1, chroma_ctrl1);
|
2005-04-17 05:20:36 +07:00
|
|
|
saa_writeb(SAA7134_CHROMA_GAIN, norm->chroma_gain);
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_CHROMA_CTRL2, norm->chroma_ctrl2);
|
|
|
|
saa_writeb(SAA7134_MODE_DELAY_CTRL, 0x00);
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_ANALOG_ADC, 0x01);
|
|
|
|
saa_writeb(SAA7134_VGATE_START, 0x11);
|
|
|
|
saa_writeb(SAA7134_VGATE_STOP, 0xfe);
|
|
|
|
saa_writeb(SAA7134_MISC_VGATE_MSB, norm->vgate_misc);
|
|
|
|
saa_writeb(SAA7134_RAW_DATA_GAIN, 0x40);
|
|
|
|
saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80);
|
|
|
|
}
|
|
|
|
|
2007-10-12 10:57:15 +07:00
|
|
|
void saa7134_set_tvnorm_hw(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
saa7134_set_decoder(dev);
|
|
|
|
|
2016-02-05 20:14:05 +07:00
|
|
|
saa_call_all(dev, video, s_std, dev->tvnorm->id);
|
2008-09-06 16:34:44 +07:00
|
|
|
/* Set the correct norm for the saa6752hs. This function
|
|
|
|
does nothing if there is no saa6752hs. */
|
2014-04-29 02:53:01 +07:00
|
|
|
saa_call_empress(dev, video, s_std, dev->tvnorm->id);
|
2007-10-12 10:57:15 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale)
|
|
|
|
{
|
|
|
|
static const struct {
|
|
|
|
int xpsc;
|
|
|
|
int xacl;
|
|
|
|
int xc2_1;
|
|
|
|
int xdcg;
|
|
|
|
int vpfy;
|
|
|
|
} vals[] = {
|
|
|
|
/* XPSC XACL XC2_1 XDCG VPFY */
|
|
|
|
{ 1, 0, 0, 0, 0 },
|
|
|
|
{ 2, 2, 1, 2, 2 },
|
|
|
|
{ 3, 4, 1, 3, 2 },
|
|
|
|
{ 4, 8, 1, 4, 2 },
|
|
|
|
{ 5, 8, 1, 4, 2 },
|
|
|
|
{ 6, 8, 1, 4, 3 },
|
|
|
|
{ 7, 8, 1, 4, 3 },
|
|
|
|
{ 8, 15, 0, 4, 3 },
|
|
|
|
{ 9, 15, 0, 4, 3 },
|
|
|
|
{ 10, 16, 1, 5, 3 },
|
|
|
|
};
|
|
|
|
static const int count = ARRAY_SIZE(vals);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
if (vals[i].xpsc == prescale)
|
|
|
|
break;
|
|
|
|
if (i == count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_H_PRESCALE(task), vals[i].xpsc);
|
|
|
|
saa_writeb(SAA7134_ACC_LENGTH(task), vals[i].xacl);
|
|
|
|
saa_writeb(SAA7134_LEVEL_CTRL(task),
|
|
|
|
(vals[i].xc2_1 << 3) | (vals[i].xdcg));
|
|
|
|
saa_andorb(SAA7134_FIR_PREFILTER_CTRL(task), 0x0f,
|
|
|
|
(vals[i].vpfy << 2) | vals[i].vpfy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_v_scale(struct saa7134_dev *dev, int task, int yscale)
|
|
|
|
{
|
|
|
|
int val,mirror;
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_V_SCALE_RATIO1(task), yscale & 0xff);
|
|
|
|
saa_writeb(SAA7134_V_SCALE_RATIO2(task), yscale >> 8);
|
|
|
|
|
|
|
|
mirror = (dev->ctl_mirror) ? 0x02 : 0x00;
|
|
|
|
if (yscale < 2048) {
|
|
|
|
/* LPI */
|
2015-05-14 00:09:42 +07:00
|
|
|
video_dbg("yscale LPI yscale=%d\n", yscale);
|
2005-04-17 05:20:36 +07:00
|
|
|
saa_writeb(SAA7134_V_FILTER(task), 0x00 | mirror);
|
|
|
|
saa_writeb(SAA7134_LUMA_CONTRAST(task), 0x40);
|
|
|
|
saa_writeb(SAA7134_CHROMA_SATURATION(task), 0x40);
|
|
|
|
} else {
|
|
|
|
/* ACM */
|
|
|
|
val = 0x40 * 1024 / yscale;
|
2015-05-14 00:09:42 +07:00
|
|
|
video_dbg("yscale ACM yscale=%d val=0x%x\n", yscale, val);
|
2005-04-17 05:20:36 +07:00
|
|
|
saa_writeb(SAA7134_V_FILTER(task), 0x01 | mirror);
|
|
|
|
saa_writeb(SAA7134_LUMA_CONTRAST(task), val);
|
|
|
|
saa_writeb(SAA7134_CHROMA_SATURATION(task), val);
|
|
|
|
}
|
|
|
|
saa_writeb(SAA7134_LUMA_BRIGHT(task), 0x80);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_size(struct saa7134_dev *dev, int task,
|
|
|
|
int width, int height, int interlace)
|
|
|
|
{
|
|
|
|
int prescale,xscale,yscale,y_even,y_odd;
|
|
|
|
int h_start, h_stop, v_start, v_stop;
|
|
|
|
int div = interlace ? 2 : 1;
|
|
|
|
|
|
|
|
/* setup video scaler */
|
|
|
|
h_start = dev->crop_current.left;
|
|
|
|
v_start = dev->crop_current.top/2;
|
|
|
|
h_stop = (dev->crop_current.left + dev->crop_current.width -1);
|
|
|
|
v_stop = (dev->crop_current.top + dev->crop_current.height -1)/2;
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_VIDEO_H_START1(task), h_start & 0xff);
|
|
|
|
saa_writeb(SAA7134_VIDEO_H_START2(task), h_start >> 8);
|
|
|
|
saa_writeb(SAA7134_VIDEO_H_STOP1(task), h_stop & 0xff);
|
|
|
|
saa_writeb(SAA7134_VIDEO_H_STOP2(task), h_stop >> 8);
|
|
|
|
saa_writeb(SAA7134_VIDEO_V_START1(task), v_start & 0xff);
|
|
|
|
saa_writeb(SAA7134_VIDEO_V_START2(task), v_start >> 8);
|
|
|
|
saa_writeb(SAA7134_VIDEO_V_STOP1(task), v_stop & 0xff);
|
|
|
|
saa_writeb(SAA7134_VIDEO_V_STOP2(task), v_stop >> 8);
|
|
|
|
|
|
|
|
prescale = dev->crop_current.width / width;
|
|
|
|
if (0 == prescale)
|
|
|
|
prescale = 1;
|
|
|
|
xscale = 1024 * dev->crop_current.width / prescale / width;
|
|
|
|
yscale = 512 * div * dev->crop_current.height / height;
|
2015-05-14 00:09:42 +07:00
|
|
|
video_dbg("prescale=%d xscale=%d yscale=%d\n",
|
|
|
|
prescale, xscale, yscale);
|
2005-04-17 05:20:36 +07:00
|
|
|
set_h_prescale(dev,task,prescale);
|
|
|
|
saa_writeb(SAA7134_H_SCALE_INC1(task), xscale & 0xff);
|
|
|
|
saa_writeb(SAA7134_H_SCALE_INC2(task), xscale >> 8);
|
|
|
|
set_v_scale(dev,task,yscale);
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_VIDEO_PIXELS1(task), width & 0xff);
|
|
|
|
saa_writeb(SAA7134_VIDEO_PIXELS2(task), width >> 8);
|
|
|
|
saa_writeb(SAA7134_VIDEO_LINES1(task), height/div & 0xff);
|
|
|
|
saa_writeb(SAA7134_VIDEO_LINES2(task), height/div >> 8);
|
|
|
|
|
|
|
|
/* deinterlace y offsets */
|
|
|
|
y_odd = dev->ctl_y_odd;
|
|
|
|
y_even = dev->ctl_y_even;
|
|
|
|
saa_writeb(SAA7134_V_PHASE_OFFSET0(task), y_odd);
|
|
|
|
saa_writeb(SAA7134_V_PHASE_OFFSET1(task), y_even);
|
|
|
|
saa_writeb(SAA7134_V_PHASE_OFFSET2(task), y_odd);
|
|
|
|
saa_writeb(SAA7134_V_PHASE_OFFSET3(task), y_even);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
struct cliplist {
|
|
|
|
__u16 position;
|
|
|
|
__u8 enable;
|
|
|
|
__u8 disable;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void set_cliplist(struct saa7134_dev *dev, int reg,
|
|
|
|
struct cliplist *cl, int entries, char *name)
|
|
|
|
{
|
|
|
|
__u8 winbits = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < entries; i++) {
|
|
|
|
winbits |= cl[i].enable;
|
|
|
|
winbits &= ~cl[i].disable;
|
|
|
|
if (i < 15 && cl[i].position == cl[i+1].position)
|
|
|
|
continue;
|
|
|
|
saa_writeb(reg + 0, winbits);
|
|
|
|
saa_writeb(reg + 2, cl[i].position & 0xff);
|
|
|
|
saa_writeb(reg + 3, cl[i].position >> 8);
|
2015-04-30 18:52:35 +07:00
|
|
|
video_dbg("clip: %s winbits=%02x pos=%d\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
name,winbits,cl[i].position);
|
|
|
|
reg += 8;
|
|
|
|
}
|
|
|
|
for (; reg < 0x400; reg += 8) {
|
|
|
|
saa_writeb(reg+ 0, 0);
|
|
|
|
saa_writeb(reg + 1, 0);
|
|
|
|
saa_writeb(reg + 2, 0);
|
|
|
|
saa_writeb(reg + 3, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clip_range(int val)
|
|
|
|
{
|
|
|
|
if (val < 0)
|
|
|
|
val = 0;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2007-04-27 22:31:18 +07:00
|
|
|
/* Sort into smallest position first order */
|
|
|
|
static int cliplist_cmp(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
const struct cliplist *cla = a;
|
|
|
|
const struct cliplist *clb = b;
|
|
|
|
if (cla->position < clb->position)
|
|
|
|
return -1;
|
|
|
|
if (cla->position > clb->position)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
static int setup_clipping(struct saa7134_dev *dev, struct v4l2_clip *clips,
|
|
|
|
int nclips, int interlace)
|
|
|
|
{
|
|
|
|
struct cliplist col[16], row[16];
|
2007-04-27 22:31:18 +07:00
|
|
|
int cols = 0, rows = 0, i;
|
2005-04-17 05:20:36 +07:00
|
|
|
int div = interlace ? 2 : 1;
|
|
|
|
|
2007-04-27 22:31:18 +07:00
|
|
|
memset(col, 0, sizeof(col));
|
|
|
|
memset(row, 0, sizeof(row));
|
2005-04-17 05:20:36 +07:00
|
|
|
for (i = 0; i < nclips && i < 8; i++) {
|
|
|
|
col[cols].position = clip_range(clips[i].c.left);
|
|
|
|
col[cols].enable = (1 << i);
|
|
|
|
cols++;
|
|
|
|
col[cols].position = clip_range(clips[i].c.left+clips[i].c.width);
|
|
|
|
col[cols].disable = (1 << i);
|
|
|
|
cols++;
|
|
|
|
row[rows].position = clip_range(clips[i].c.top / div);
|
|
|
|
row[rows].enable = (1 << i);
|
|
|
|
rows++;
|
|
|
|
row[rows].position = clip_range((clips[i].c.top + clips[i].c.height)
|
|
|
|
/ div);
|
|
|
|
row[rows].disable = (1 << i);
|
|
|
|
rows++;
|
|
|
|
}
|
2007-04-27 22:31:18 +07:00
|
|
|
sort(col, cols, sizeof col[0], cliplist_cmp, NULL);
|
|
|
|
sort(row, rows, sizeof row[0], cliplist_cmp, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
set_cliplist(dev,0x380,col,cols,"cols");
|
|
|
|
set_cliplist(dev,0x384,row,rows,"rows");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-31 21:48:50 +07:00
|
|
|
static int verify_preview(struct saa7134_dev *dev, struct v4l2_window *win, bool try)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
enum v4l2_field field;
|
|
|
|
int maxw, maxh;
|
|
|
|
|
2013-05-31 21:48:50 +07:00
|
|
|
if (!try && (dev->ovbuf.base == NULL || dev->ovfmt == NULL))
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
2013-05-31 21:48:50 +07:00
|
|
|
if (win->w.width < 48)
|
|
|
|
win->w.width = 48;
|
|
|
|
if (win->w.height < 32)
|
|
|
|
win->w.height = 32;
|
|
|
|
if (win->clipcount > 8)
|
|
|
|
win->clipcount = 8;
|
|
|
|
|
|
|
|
win->chromakey = 0;
|
|
|
|
win->global_alpha = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
field = win->field;
|
|
|
|
maxw = dev->crop_current.width;
|
|
|
|
maxh = dev->crop_current.height;
|
|
|
|
|
|
|
|
if (V4L2_FIELD_ANY == field) {
|
2005-11-09 12:37:43 +07:00
|
|
|
field = (win->w.height > maxh/2)
|
|
|
|
? V4L2_FIELD_INTERLACED
|
|
|
|
: V4L2_FIELD_TOP;
|
|
|
|
}
|
|
|
|
switch (field) {
|
|
|
|
case V4L2_FIELD_TOP:
|
|
|
|
case V4L2_FIELD_BOTTOM:
|
|
|
|
maxh = maxh / 2;
|
|
|
|
break;
|
|
|
|
default:
|
2013-05-31 21:48:50 +07:00
|
|
|
field = V4L2_FIELD_INTERLACED;
|
|
|
|
break;
|
2005-11-09 12:37:43 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
win->field = field;
|
|
|
|
if (win->w.width > maxw)
|
|
|
|
win->w.width = maxw;
|
|
|
|
if (win->w.height > maxh)
|
|
|
|
win->w.height = maxh;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-14 18:28:24 +07:00
|
|
|
static int start_preview(struct saa7134_dev *dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
unsigned long base,control,bpl;
|
|
|
|
int err;
|
|
|
|
|
2013-05-31 21:48:50 +07:00
|
|
|
err = verify_preview(dev, &dev->win, false);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (0 != err)
|
|
|
|
return err;
|
|
|
|
|
2013-05-31 18:22:24 +07:00
|
|
|
dev->ovfield = dev->win.field;
|
2015-04-30 18:52:35 +07:00
|
|
|
video_dbg("start_preview %dx%d+%d+%d %s field=%s\n",
|
2013-05-31 18:22:24 +07:00
|
|
|
dev->win.w.width, dev->win.w.height,
|
|
|
|
dev->win.w.left, dev->win.w.top,
|
|
|
|
dev->ovfmt->name, v4l2_field_names[dev->ovfield]);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* setup window + clipping */
|
2013-05-31 18:22:24 +07:00
|
|
|
set_size(dev, TASK_B, dev->win.w.width, dev->win.w.height,
|
2005-04-17 05:20:36 +07:00
|
|
|
V4L2_FIELD_HAS_BOTH(dev->ovfield));
|
2013-05-31 18:22:24 +07:00
|
|
|
setup_clipping(dev, dev->clips, dev->nclips,
|
2005-04-17 05:20:36 +07:00
|
|
|
V4L2_FIELD_HAS_BOTH(dev->ovfield));
|
|
|
|
if (dev->ovfmt->yuv)
|
|
|
|
saa_andorb(SAA7134_DATA_PATH(TASK_B), 0x3f, 0x03);
|
|
|
|
else
|
|
|
|
saa_andorb(SAA7134_DATA_PATH(TASK_B), 0x3f, 0x01);
|
|
|
|
saa_writeb(SAA7134_OFMT_VIDEO_B, dev->ovfmt->pm | 0x20);
|
|
|
|
|
|
|
|
/* dma: setup channel 1 (= Video Task B) */
|
|
|
|
base = (unsigned long)dev->ovbuf.base;
|
2013-05-31 18:22:24 +07:00
|
|
|
base += dev->ovbuf.fmt.bytesperline * dev->win.w.top;
|
|
|
|
base += dev->ovfmt->depth/8 * dev->win.w.left;
|
2005-04-17 05:20:36 +07:00
|
|
|
bpl = dev->ovbuf.fmt.bytesperline;
|
|
|
|
control = SAA7134_RS_CONTROL_BURST_16;
|
|
|
|
if (dev->ovfmt->bswap)
|
|
|
|
control |= SAA7134_RS_CONTROL_BSWAP;
|
|
|
|
if (dev->ovfmt->wswap)
|
|
|
|
control |= SAA7134_RS_CONTROL_WSWAP;
|
|
|
|
if (V4L2_FIELD_HAS_BOTH(dev->ovfield)) {
|
|
|
|
saa_writel(SAA7134_RS_BA1(1),base);
|
|
|
|
saa_writel(SAA7134_RS_BA2(1),base+bpl);
|
|
|
|
saa_writel(SAA7134_RS_PITCH(1),bpl*2);
|
|
|
|
saa_writel(SAA7134_RS_CONTROL(1),control);
|
|
|
|
} else {
|
|
|
|
saa_writel(SAA7134_RS_BA1(1),base);
|
|
|
|
saa_writel(SAA7134_RS_BA2(1),base);
|
|
|
|
saa_writel(SAA7134_RS_PITCH(1),bpl);
|
|
|
|
saa_writel(SAA7134_RS_CONTROL(1),control);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start dma */
|
|
|
|
dev->ovenable = 1;
|
|
|
|
saa7134_set_dmabits(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-14 18:28:24 +07:00
|
|
|
static int stop_preview(struct saa7134_dev *dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
dev->ovenable = 0;
|
|
|
|
saa7134_set_dmabits(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-05 17:33:04 +07:00
|
|
|
/*
|
|
|
|
* Media Controller helper functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int saa7134_enable_analog_tuner(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_MEDIA_CONTROLLER
|
|
|
|
struct media_device *mdev = dev->media_dev;
|
|
|
|
struct media_entity *source;
|
|
|
|
struct media_link *link, *found_link = NULL;
|
|
|
|
int ret, active_links = 0;
|
|
|
|
|
|
|
|
if (!mdev || !dev->decoder)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This will find the tuner that is connected into the decoder.
|
|
|
|
* Technically, this is not 100% correct, as the device may be
|
|
|
|
* using an analog input instead of the tuner. However, as we can't
|
|
|
|
* do DVB streaming while the DMA engine is being used for V4L2,
|
|
|
|
* this should be enough for the actual needs.
|
|
|
|
*/
|
|
|
|
list_for_each_entry(link, &dev->decoder->links, list) {
|
|
|
|
if (link->sink->entity == dev->decoder) {
|
|
|
|
found_link = link;
|
|
|
|
if (link->flags & MEDIA_LNK_FL_ENABLED)
|
|
|
|
active_links++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (active_links == 1 || !found_link)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
source = found_link->source->entity;
|
|
|
|
list_for_each_entry(link, &source->links, list) {
|
|
|
|
struct media_entity *sink;
|
|
|
|
int flags = 0;
|
|
|
|
|
|
|
|
sink = link->sink->entity;
|
|
|
|
|
|
|
|
if (sink == dev->decoder)
|
|
|
|
flags = MEDIA_LNK_FL_ENABLED;
|
|
|
|
|
|
|
|
ret = media_entity_setup_link(link, flags);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("Couldn't change link %s->%s to %s. Error %d\n",
|
|
|
|
source->name, sink->name,
|
|
|
|
flags ? "enabled" : "disabled",
|
|
|
|
ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
static int buffer_activate(struct saa7134_dev *dev,
|
|
|
|
struct saa7134_buf *buf,
|
|
|
|
struct saa7134_buf *next)
|
|
|
|
{
|
[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 saa7134_dmaqueue *dmaq = buf->vb2.vb2_buf.vb2_queue->drv_priv;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long base,control,bpl;
|
|
|
|
unsigned long bpl_uv,lines_uv,base2,base3,tmp; /* planar */
|
|
|
|
|
2015-05-14 00:09:42 +07:00
|
|
|
video_dbg("buffer_activate buf=%p\n", buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
buf->top_seen = 0;
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
set_size(dev, TASK_A, dev->width, dev->height,
|
|
|
|
V4L2_FIELD_HAS_BOTH(dev->field));
|
2014-04-17 15:00:39 +07:00
|
|
|
if (dev->fmt->yuv)
|
2005-04-17 05:20:36 +07:00
|
|
|
saa_andorb(SAA7134_DATA_PATH(TASK_A), 0x3f, 0x03);
|
|
|
|
else
|
|
|
|
saa_andorb(SAA7134_DATA_PATH(TASK_A), 0x3f, 0x01);
|
2014-04-17 15:00:39 +07:00
|
|
|
saa_writeb(SAA7134_OFMT_VIDEO_A, dev->fmt->pm);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* DMA: setup channel 0 (= Video Task A0) */
|
|
|
|
base = saa7134_buffer_base(buf);
|
2014-04-17 15:00:39 +07:00
|
|
|
if (dev->fmt->planar)
|
2014-04-17 17:30:53 +07:00
|
|
|
bpl = dev->width;
|
2005-04-17 05:20:36 +07:00
|
|
|
else
|
2014-04-17 17:30:53 +07:00
|
|
|
bpl = (dev->width * dev->fmt->depth) / 8;
|
2005-04-17 05:20:36 +07:00
|
|
|
control = SAA7134_RS_CONTROL_BURST_16 |
|
|
|
|
SAA7134_RS_CONTROL_ME |
|
2014-04-17 17:30:53 +07:00
|
|
|
(dmaq->pt.dma >> 12);
|
2014-04-17 15:00:39 +07:00
|
|
|
if (dev->fmt->bswap)
|
2005-04-17 05:20:36 +07:00
|
|
|
control |= SAA7134_RS_CONTROL_BSWAP;
|
2014-04-17 15:00:39 +07:00
|
|
|
if (dev->fmt->wswap)
|
2005-04-17 05:20:36 +07:00
|
|
|
control |= SAA7134_RS_CONTROL_WSWAP;
|
2014-04-17 17:30:53 +07:00
|
|
|
if (V4L2_FIELD_HAS_BOTH(dev->field)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* interlaced */
|
|
|
|
saa_writel(SAA7134_RS_BA1(0),base);
|
|
|
|
saa_writel(SAA7134_RS_BA2(0),base+bpl);
|
|
|
|
saa_writel(SAA7134_RS_PITCH(0),bpl*2);
|
|
|
|
} else {
|
|
|
|
/* non-interlaced */
|
|
|
|
saa_writel(SAA7134_RS_BA1(0),base);
|
|
|
|
saa_writel(SAA7134_RS_BA2(0),base);
|
|
|
|
saa_writel(SAA7134_RS_PITCH(0),bpl);
|
|
|
|
}
|
|
|
|
saa_writel(SAA7134_RS_CONTROL(0),control);
|
|
|
|
|
2014-04-17 15:00:39 +07:00
|
|
|
if (dev->fmt->planar) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* DMA: setup channel 4+5 (= planar task A) */
|
2014-04-17 15:00:39 +07:00
|
|
|
bpl_uv = bpl >> dev->fmt->hshift;
|
2014-04-17 17:30:53 +07:00
|
|
|
lines_uv = dev->height >> dev->fmt->vshift;
|
|
|
|
base2 = base + bpl * dev->height;
|
2005-04-17 05:20:36 +07:00
|
|
|
base3 = base2 + bpl_uv * lines_uv;
|
2014-04-17 15:00:39 +07:00
|
|
|
if (dev->fmt->uvswap)
|
2005-04-17 05:20:36 +07:00
|
|
|
tmp = base2, base2 = base3, base3 = tmp;
|
2015-04-30 18:52:35 +07:00
|
|
|
video_dbg("uv: bpl=%ld lines=%ld base2/3=%ld/%ld\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
bpl_uv,lines_uv,base2,base3);
|
2014-04-17 17:30:53 +07:00
|
|
|
if (V4L2_FIELD_HAS_BOTH(dev->field)) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* interlaced */
|
|
|
|
saa_writel(SAA7134_RS_BA1(4),base2);
|
|
|
|
saa_writel(SAA7134_RS_BA2(4),base2+bpl_uv);
|
|
|
|
saa_writel(SAA7134_RS_PITCH(4),bpl_uv*2);
|
|
|
|
saa_writel(SAA7134_RS_BA1(5),base3);
|
|
|
|
saa_writel(SAA7134_RS_BA2(5),base3+bpl_uv);
|
|
|
|
saa_writel(SAA7134_RS_PITCH(5),bpl_uv*2);
|
|
|
|
} else {
|
|
|
|
/* non-interlaced */
|
|
|
|
saa_writel(SAA7134_RS_BA1(4),base2);
|
|
|
|
saa_writel(SAA7134_RS_BA2(4),base2);
|
|
|
|
saa_writel(SAA7134_RS_PITCH(4),bpl_uv);
|
|
|
|
saa_writel(SAA7134_RS_BA1(5),base3);
|
|
|
|
saa_writel(SAA7134_RS_BA2(5),base3);
|
|
|
|
saa_writel(SAA7134_RS_PITCH(5),bpl_uv);
|
|
|
|
}
|
|
|
|
saa_writel(SAA7134_RS_CONTROL(4),control);
|
|
|
|
saa_writel(SAA7134_RS_CONTROL(5),control);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start DMA */
|
|
|
|
saa7134_set_dmabits(dev);
|
2014-04-17 17:30:53 +07:00
|
|
|
mod_timer(&dmaq->timeout, jiffies + BUFFER_TIMEOUT);
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
static int buffer_init(struct vb2_buffer *vb2)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2014-04-17 17:30:53 +07:00
|
|
|
struct saa7134_dmaqueue *dmaq = vb2->vb2_queue->drv_priv;
|
[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 *vbuf = to_vb2_v4l2_buffer(vb2);
|
|
|
|
struct saa7134_buf *buf = container_of(vbuf, struct saa7134_buf, vb2);
|
2014-04-17 17:30:53 +07:00
|
|
|
|
|
|
|
dmaq->curr = NULL;
|
|
|
|
buf->activate = buffer_activate;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int buffer_prepare(struct vb2_buffer *vb2)
|
|
|
|
{
|
|
|
|
struct saa7134_dmaqueue *dmaq = vb2->vb2_queue->drv_priv;
|
2014-04-17 16:06:06 +07:00
|
|
|
struct saa7134_dev *dev = dmaq->dev;
|
[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 *vbuf = to_vb2_v4l2_buffer(vb2);
|
|
|
|
struct saa7134_buf *buf = container_of(vbuf, struct saa7134_buf, vb2);
|
|
|
|
struct sg_table *dma = vb2_dma_sg_plane_desc(vb2, 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned int size;
|
|
|
|
|
2014-04-17 16:44:31 +07:00
|
|
|
if (dma->sgl->offset) {
|
|
|
|
pr_err("The buffer is not page-aligned\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2014-04-17 17:30:53 +07:00
|
|
|
size = (dev->width * dev->height * dev->fmt->depth) >> 3;
|
|
|
|
if (vb2_plane_size(vb2, 0) < size)
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
2014-04-17 17:30:53 +07:00
|
|
|
|
|
|
|
vb2_set_plane_payload(vb2, 0, size);
|
[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
|
|
|
vbuf->field = dev->field;
|
2014-04-17 17:30:53 +07:00
|
|
|
|
|
|
|
return saa7134_pgtable_build(dev->pci, &dmaq->pt, dma->sgl, dma->nents,
|
|
|
|
saa7134_buffer_startpage(buf));
|
|
|
|
}
|
|
|
|
|
2015-10-28 09:50:37 +07:00
|
|
|
static int queue_setup(struct vb2_queue *q,
|
2014-04-17 17:30:53 +07:00
|
|
|
unsigned int *nbuffers, unsigned int *nplanes,
|
2016-04-15 19:15:05 +07:00
|
|
|
unsigned int sizes[], struct device *alloc_devs[])
|
2014-04-17 17:30:53 +07:00
|
|
|
{
|
|
|
|
struct saa7134_dmaqueue *dmaq = q->drv_priv;
|
|
|
|
struct saa7134_dev *dev = dmaq->dev;
|
|
|
|
int size = dev->fmt->depth * dev->width * dev->height >> 3;
|
|
|
|
|
2013-05-31 18:30:49 +07:00
|
|
|
if (dev->width < 48 ||
|
|
|
|
dev->height < 32 ||
|
|
|
|
dev->width/4 > dev->crop_current.width ||
|
|
|
|
dev->height/4 > dev->crop_current.height ||
|
|
|
|
dev->width > dev->crop_bounds.width ||
|
|
|
|
dev->height > dev->crop_bounds.height)
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
*nbuffers = saa7134_buffer_count(size, *nbuffers);
|
|
|
|
*nplanes = 1;
|
|
|
|
sizes[0] = size;
|
2016-02-05 17:33:04 +07:00
|
|
|
|
|
|
|
saa7134_enable_analog_tuner(dev);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
/*
|
|
|
|
* move buffer to hardware queue
|
|
|
|
*/
|
|
|
|
void saa7134_vb2_buffer_queue(struct vb2_buffer *vb)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2014-04-17 17:30:53 +07:00
|
|
|
struct saa7134_dmaqueue *dmaq = vb->vb2_queue->drv_priv;
|
2014-04-17 16:06:06 +07:00
|
|
|
struct saa7134_dev *dev = dmaq->dev;
|
[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 *vbuf = to_vb2_v4l2_buffer(vb);
|
|
|
|
struct saa7134_buf *buf = container_of(vbuf, struct saa7134_buf, vb2);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
saa7134_buffer_queue(dev, dmaq, buf);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2014-04-17 17:30:53 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_vb2_buffer_queue);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
int saa7134_vb2_start_streaming(struct vb2_queue *vq, unsigned int count)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2014-04-17 17:30:53 +07:00
|
|
|
struct saa7134_dmaqueue *dmaq = vq->drv_priv;
|
2014-04-17 16:06:06 +07:00
|
|
|
struct saa7134_dev *dev = dmaq->dev;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
/*
|
|
|
|
* Planar video capture and TS share the same DMA channel,
|
|
|
|
* so only one can be active at a time.
|
|
|
|
*/
|
|
|
|
if (card_is_empress(dev) && vb2_is_busy(&dev->empress_vbq) &&
|
|
|
|
dmaq == &dev->video_q && dev->fmt->planar) {
|
|
|
|
struct saa7134_buf *buf, *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(buf, tmp, &dmaq->queue, entry) {
|
|
|
|
list_del(&buf->entry);
|
[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
|
|
|
vb2_buffer_done(&buf->vb2.vb2_buf,
|
|
|
|
VB2_BUF_STATE_QUEUED);
|
2014-04-17 17:30:53 +07:00
|
|
|
}
|
|
|
|
if (dmaq->curr) {
|
[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
|
|
|
vb2_buffer_done(&dmaq->curr->vb2.vb2_buf,
|
|
|
|
VB2_BUF_STATE_QUEUED);
|
2014-04-17 17:30:53 +07:00
|
|
|
dmaq->curr = NULL;
|
|
|
|
}
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The SAA7134 has a 1K FIFO; the datasheet suggests that when
|
|
|
|
* configured conservatively, there's 22 usec of buffering for video.
|
|
|
|
* We therefore request a DMA latency of 20 usec, giving us 2 usec of
|
|
|
|
* margin in case the FIFO is configured differently to the datasheet.
|
|
|
|
* Unfortunately, I lack register-level documentation to check the
|
|
|
|
* Linux FIFO setup and confirm the perfect value.
|
|
|
|
*/
|
|
|
|
if ((dmaq == &dev->video_q && !vb2_is_streaming(&dev->vbi_vbq)) ||
|
|
|
|
(dmaq == &dev->vbi_q && !vb2_is_streaming(&dev->video_vbq)))
|
|
|
|
pm_qos_add_request(&dev->qos_request,
|
|
|
|
PM_QOS_CPU_DMA_LATENCY, 20);
|
|
|
|
dmaq->seq_nr = 0;
|
|
|
|
|
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
void saa7134_vb2_stop_streaming(struct vb2_queue *vq)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2014-04-17 17:30:53 +07:00
|
|
|
struct saa7134_dmaqueue *dmaq = vq->drv_priv;
|
|
|
|
struct saa7134_dev *dev = dmaq->dev;
|
|
|
|
|
|
|
|
saa7134_stop_streaming(dev, dmaq);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
if ((dmaq == &dev->video_q && !vb2_is_streaming(&dev->vbi_vbq)) ||
|
|
|
|
(dmaq == &dev->vbi_q && !vb2_is_streaming(&dev->video_vbq)))
|
|
|
|
pm_qos_remove_request(&dev->qos_request);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2016-09-09 06:59:18 +07:00
|
|
|
static const struct vb2_ops vb2_qops = {
|
2014-04-17 17:30:53 +07:00
|
|
|
.queue_setup = queue_setup,
|
|
|
|
.buf_init = buffer_init,
|
|
|
|
.buf_prepare = buffer_prepare,
|
|
|
|
.buf_queue = saa7134_vb2_buffer_queue,
|
|
|
|
.wait_prepare = vb2_ops_wait_prepare,
|
|
|
|
.wait_finish = vb2_ops_wait_finish,
|
|
|
|
.start_streaming = saa7134_vb2_start_streaming,
|
|
|
|
.stop_streaming = saa7134_vb2_stop_streaming,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2013-12-14 18:28:24 +07:00
|
|
|
static int saa7134_s_ctrl(struct v4l2_ctrl *ctrl)
|
2008-07-26 19:04:06 +07:00
|
|
|
{
|
2013-12-14 18:28:24 +07:00
|
|
|
struct saa7134_dev *dev = container_of(ctrl->handler, struct saa7134_dev, ctrl_handler);
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long flags;
|
|
|
|
int restart_overlay = 0;
|
|
|
|
|
2013-12-14 18:28:24 +07:00
|
|
|
switch (ctrl->id) {
|
2005-04-17 05:20:36 +07:00
|
|
|
case V4L2_CID_BRIGHTNESS:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_bright = ctrl->val;
|
|
|
|
saa_writeb(SAA7134_DEC_LUMA_BRIGHT, ctrl->val);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_HUE:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_hue = ctrl->val;
|
|
|
|
saa_writeb(SAA7134_DEC_CHROMA_HUE, ctrl->val);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
case V4L2_CID_CONTRAST:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_contrast = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
saa_writeb(SAA7134_DEC_LUMA_CONTRAST,
|
|
|
|
dev->ctl_invert ? -dev->ctl_contrast : dev->ctl_contrast);
|
|
|
|
break;
|
|
|
|
case V4L2_CID_SATURATION:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_saturation = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
saa_writeb(SAA7134_DEC_CHROMA_SATURATION,
|
|
|
|
dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation);
|
|
|
|
break;
|
|
|
|
case V4L2_CID_AUDIO_MUTE:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_mute = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
saa7134_tvaudio_setmute(dev);
|
|
|
|
break;
|
|
|
|
case V4L2_CID_AUDIO_VOLUME:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_volume = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
saa7134_tvaudio_setvolume(dev,dev->ctl_volume);
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_INVERT:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_invert = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
saa_writeb(SAA7134_DEC_LUMA_CONTRAST,
|
|
|
|
dev->ctl_invert ? -dev->ctl_contrast : dev->ctl_contrast);
|
|
|
|
saa_writeb(SAA7134_DEC_CHROMA_SATURATION,
|
|
|
|
dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation);
|
|
|
|
break;
|
2005-06-24 12:04:47 +07:00
|
|
|
case V4L2_CID_HFLIP:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_mirror = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
restart_overlay = 1;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_Y_EVEN:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_y_even = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
restart_overlay = 1;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_Y_ODD:
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_y_odd = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
restart_overlay = 1;
|
|
|
|
break;
|
|
|
|
case V4L2_CID_PRIVATE_AUTOMUTE:
|
2007-10-19 05:56:47 +07:00
|
|
|
{
|
|
|
|
struct v4l2_priv_tun_config tda9887_cfg;
|
|
|
|
|
|
|
|
tda9887_cfg.tuner = TUNER_TDA9887;
|
|
|
|
tda9887_cfg.priv = &dev->tda9887_conf;
|
|
|
|
|
2013-12-14 18:28:24 +07:00
|
|
|
dev->ctl_automute = ctrl->val;
|
2005-04-17 05:20:36 +07:00
|
|
|
if (dev->tda9887_conf) {
|
|
|
|
if (dev->ctl_automute)
|
|
|
|
dev->tda9887_conf |= TDA9887_AUTOMUTE;
|
|
|
|
else
|
|
|
|
dev->tda9887_conf &= ~TDA9887_AUTOMUTE;
|
2007-10-19 05:56:47 +07:00
|
|
|
|
2009-01-17 22:17:14 +07:00
|
|
|
saa_call_all(dev, tuner, s_config, &tda9887_cfg);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
break;
|
2007-10-19 05:56:47 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
default:
|
2013-12-14 18:28:24 +07:00
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2014-04-17 17:30:53 +07:00
|
|
|
if (restart_overlay && dev->overlay_owner) {
|
2013-12-14 18:28:24 +07:00
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
|
|
|
stop_preview(dev);
|
|
|
|
start_preview(dev);
|
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2013-12-14 18:28:24 +07:00
|
|
|
return 0;
|
2008-07-26 19:04:06 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int video_open(struct file *file)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-12-10 20:44:04 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2014-04-17 17:30:53 +07:00
|
|
|
int ret = v4l2_fh_open(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
mutex_lock(&dev->lock);
|
2013-05-31 17:57:10 +07:00
|
|
|
if (vdev->vfl_type == VFL_TYPE_RADIO) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* switch to radio mode */
|
2014-04-17 13:48:50 +07:00
|
|
|
saa7134_tvaudio_setinput(dev, &card(dev).radio);
|
2009-01-17 22:17:14 +07:00
|
|
|
saa_call_all(dev, tuner, s_radio);
|
2005-04-17 05:20:36 +07:00
|
|
|
} else {
|
|
|
|
/* switch to video/vbi mode */
|
2014-04-17 13:48:50 +07:00
|
|
|
video_mux(dev, dev->ctl_input);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2014-04-17 17:30:53 +07:00
|
|
|
mutex_unlock(&dev->lock);
|
2013-02-02 06:01:16 +07:00
|
|
|
|
2005-07-13 03:59:01 +07:00
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int video_release(struct file *file)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-05-31 17:57:10 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2014-04-17 17:30:53 +07:00
|
|
|
struct v4l2_fh *fh = file->private_data;
|
2010-12-27 22:22:46 +07:00
|
|
|
struct saa6588_command cmd;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long flags;
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
mutex_lock(&dev->lock);
|
2011-12-04 02:40:45 +07:00
|
|
|
saa7134_tvaudio_close(dev);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* turn off overlay */
|
2014-04-17 17:30:53 +07:00
|
|
|
if (fh == dev->overlay_owner) {
|
2005-04-17 05:20:36 +07:00
|
|
|
spin_lock_irqsave(&dev->slock,flags);
|
2013-12-14 18:28:24 +07:00
|
|
|
stop_preview(dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
spin_unlock_irqrestore(&dev->slock,flags);
|
2014-04-17 17:30:53 +07:00
|
|
|
dev->overlay_owner = NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
if (vdev->vfl_type == VFL_TYPE_RADIO)
|
|
|
|
v4l2_fh_release(file);
|
|
|
|
else
|
|
|
|
_vb2_fop_release(file, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2005-07-13 03:59:01 +07:00
|
|
|
/* ts-capture will not work in planar mode, so turn it off Hac: 04.05*/
|
|
|
|
saa_andorb(SAA7134_OFMT_VIDEO_A, 0x1f, 0);
|
|
|
|
saa_andorb(SAA7134_OFMT_VIDEO_B, 0x1f, 0);
|
|
|
|
saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0);
|
|
|
|
saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0);
|
|
|
|
|
media: add tuner standby op, use where needed
The v4l2_subdev core s_power op was used for two different things: power on/off
sensors or video decoders/encoders and to put a tuner in standby (and only the
tuner!). There is no 'tuner wakeup' op, that's done automatically when the tuner
is accessed.
The danger with calling (s_power, 0) to put a tuner into standby is that it is
usually broadcast for all subdevs. So a video receiver subdev that supports
s_power will also be powered off, and since there is no corresponding (s_power, 1)
they will never be powered on again.
In addition, this is specifically meant for tuners only since they draw the most
current.
This patch adds a new tuner op called 'standby' and replaces all calls to
(core, s_power, 0) by (tuner, standby). This prevents confusion between the two
uses of s_power. Note that there is no overlap: bridge drivers either just want
to put the tuner into standby, or they deal with powering on/off sensors. Never
both.
This also makes it easier to replace s_power for the remaining bridge drivers
with some PM code later.
Whether we want something cleaner for tuners in the future is a separate topic.
There is a lot of legacy code surrounding tuners, and I am very hesitant about
making changes there.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-02-21 14:49:25 +07:00
|
|
|
saa_call_all(dev, tuner, standby);
|
2013-05-31 17:57:10 +07:00
|
|
|
if (vdev->vfl_type == VFL_TYPE_RADIO)
|
2010-12-27 22:22:46 +07:00
|
|
|
saa_call_all(dev, core, ioctl, SAA6588_CMD_CLOSE, &cmd);
|
2014-04-17 17:30:53 +07:00
|
|
|
mutex_unlock(&dev->lock);
|
2005-07-13 03:59:01 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-29 16:26:27 +07:00
|
|
|
static ssize_t radio_read(struct file *file, char __user *data,
|
|
|
|
size_t count, loff_t *ppos)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2010-12-27 22:22:46 +07:00
|
|
|
struct saa6588_command cmd;
|
2009-03-29 16:26:27 +07:00
|
|
|
|
|
|
|
cmd.block_count = count/3;
|
2013-12-14 18:28:36 +07:00
|
|
|
cmd.nonblocking = file->f_flags & O_NONBLOCK;
|
2009-03-29 16:26:27 +07:00
|
|
|
cmd.buffer = data;
|
|
|
|
cmd.instance = file;
|
|
|
|
cmd.result = -ENODEV;
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
mutex_lock(&dev->lock);
|
2010-12-27 22:22:46 +07:00
|
|
|
saa_call_all(dev, core, ioctl, SAA6588_CMD_READ, &cmd);
|
2014-04-17 17:30:53 +07:00
|
|
|
mutex_unlock(&dev->lock);
|
2009-03-29 16:26:27 +07:00
|
|
|
|
|
|
|
return cmd.result;
|
|
|
|
}
|
|
|
|
|
2017-07-03 14:02:56 +07:00
|
|
|
static __poll_t radio_poll(struct file *file, poll_table *wait)
|
2009-03-29 16:26:27 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2010-12-27 22:22:46 +07:00
|
|
|
struct saa6588_command cmd;
|
2017-07-03 14:02:56 +07:00
|
|
|
__poll_t rc = v4l2_ctrl_poll(file, wait);
|
2009-03-29 16:26:27 +07:00
|
|
|
|
|
|
|
cmd.instance = file;
|
|
|
|
cmd.event_list = wait;
|
2018-02-16 01:11:48 +07:00
|
|
|
cmd.poll_mask = 0;
|
2014-04-17 17:30:53 +07:00
|
|
|
mutex_lock(&dev->lock);
|
2010-12-27 22:22:46 +07:00
|
|
|
saa_call_all(dev, core, ioctl, SAA6588_CMD_POLL, &cmd);
|
2014-04-17 17:30:53 +07:00
|
|
|
mutex_unlock(&dev->lock);
|
2009-03-29 16:26:27 +07:00
|
|
|
|
2018-02-16 01:11:48 +07:00
|
|
|
return rc | cmd.poll_mask;
|
2009-03-29 16:26:27 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_try_get_set_fmt_vbi_cap(struct file *file, void *priv,
|
2007-12-08 03:34:48 +07:00
|
|
|
struct v4l2_format *f)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct saa7134_tvnorm *norm = dev->tvnorm;
|
|
|
|
|
2013-02-02 06:01:21 +07:00
|
|
|
memset(&f->fmt.vbi.reserved, 0, sizeof(f->fmt.vbi.reserved));
|
2005-04-17 05:20:36 +07:00
|
|
|
f->fmt.vbi.sampling_rate = 6750000 * 4;
|
|
|
|
f->fmt.vbi.samples_per_line = 2048 /* VBI_LINE_LENGTH */;
|
|
|
|
f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
|
|
|
|
f->fmt.vbi.offset = 64 * 4;
|
2005-06-24 12:04:47 +07:00
|
|
|
f->fmt.vbi.start[0] = norm->vbi_v_start_0;
|
|
|
|
f->fmt.vbi.count[0] = norm->vbi_v_stop_0 - norm->vbi_v_start_0 +1;
|
|
|
|
f->fmt.vbi.start[1] = norm->vbi_v_start_1;
|
2005-04-17 05:20:36 +07:00
|
|
|
f->fmt.vbi.count[1] = f->fmt.vbi.count[0];
|
|
|
|
f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */
|
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_g_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-08 03:09:53 +07:00
|
|
|
struct v4l2_format *f)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:09:53 +07:00
|
|
|
|
2013-05-31 18:30:49 +07:00
|
|
|
f->fmt.pix.width = dev->width;
|
|
|
|
f->fmt.pix.height = dev->height;
|
2014-04-17 17:30:53 +07:00
|
|
|
f->fmt.pix.field = dev->field;
|
2013-05-31 18:30:49 +07:00
|
|
|
f->fmt.pix.pixelformat = dev->fmt->fourcc;
|
2016-02-15 02:51:37 +07:00
|
|
|
if (dev->fmt->planar)
|
|
|
|
f->fmt.pix.bytesperline = f->fmt.pix.width;
|
|
|
|
else
|
|
|
|
f->fmt.pix.bytesperline =
|
|
|
|
(f->fmt.pix.width * dev->fmt->depth) / 8;
|
2007-12-08 03:34:48 +07:00
|
|
|
f->fmt.pix.sizeimage =
|
2016-02-15 02:51:37 +07:00
|
|
|
(f->fmt.pix.height * f->fmt.pix.width * dev->fmt->depth) / 8;
|
2013-05-31 21:48:50 +07:00
|
|
|
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
|
2007-12-08 03:34:48 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_g_fmt_vid_overlay(struct file *file, void *priv,
|
2007-12-08 03:34:48 +07:00
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2013-06-22 18:02:52 +07:00
|
|
|
struct v4l2_clip __user *clips = f->fmt.win.clips;
|
2013-05-31 21:48:50 +07:00
|
|
|
u32 clipcount = f->fmt.win.clipcount;
|
|
|
|
int err = 0;
|
|
|
|
int i;
|
2007-12-08 03:34:48 +07:00
|
|
|
|
|
|
|
if (saa7134_no_overlay > 0) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 16:46:34 +07:00
|
|
|
pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2013-05-31 18:22:24 +07:00
|
|
|
f->fmt.win = dev->win;
|
2013-05-31 21:48:50 +07:00
|
|
|
f->fmt.win.clips = clips;
|
|
|
|
if (clips == NULL)
|
|
|
|
clipcount = 0;
|
|
|
|
if (dev->nclips < clipcount)
|
|
|
|
clipcount = dev->nclips;
|
|
|
|
f->fmt.win.clipcount = clipcount;
|
|
|
|
|
|
|
|
for (i = 0; !err && i < clipcount; i++) {
|
|
|
|
if (copy_to_user(&f->fmt.win.clips[i].c, &dev->clips[i].c,
|
|
|
|
sizeof(struct v4l2_rect)))
|
|
|
|
err = -EFAULT;
|
|
|
|
}
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2013-05-31 21:48:50 +07:00
|
|
|
return err;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_try_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-08 03:09:53 +07:00
|
|
|
struct v4l2_format *f)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:34:48 +07:00
|
|
|
struct saa7134_format *fmt;
|
|
|
|
enum v4l2_field field;
|
|
|
|
unsigned int maxw, maxh;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
fmt = format_by_fourcc(f->fmt.pix.pixelformat);
|
|
|
|
if (NULL == fmt)
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
field = f->fmt.pix.field;
|
|
|
|
maxw = min(dev->crop_current.width*4, dev->crop_bounds.width);
|
|
|
|
maxh = min(dev->crop_current.height*4, dev->crop_bounds.height);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
if (V4L2_FIELD_ANY == field) {
|
|
|
|
field = (f->fmt.pix.height > maxh/2)
|
|
|
|
? V4L2_FIELD_INTERLACED
|
|
|
|
: V4L2_FIELD_BOTTOM;
|
|
|
|
}
|
|
|
|
switch (field) {
|
|
|
|
case V4L2_FIELD_TOP:
|
|
|
|
case V4L2_FIELD_BOTTOM:
|
|
|
|
maxh = maxh / 2;
|
|
|
|
break;
|
|
|
|
default:
|
2013-05-31 21:48:50 +07:00
|
|
|
field = V4L2_FIELD_INTERLACED;
|
|
|
|
break;
|
2007-12-08 03:34:48 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
f->fmt.pix.field = field;
|
2010-03-20 00:58:23 +07:00
|
|
|
if (f->fmt.pix.width < 48)
|
|
|
|
f->fmt.pix.width = 48;
|
|
|
|
if (f->fmt.pix.height < 32)
|
|
|
|
f->fmt.pix.height = 32;
|
|
|
|
if (f->fmt.pix.width > maxw)
|
|
|
|
f->fmt.pix.width = maxw;
|
|
|
|
if (f->fmt.pix.height > maxh)
|
|
|
|
f->fmt.pix.height = maxh;
|
|
|
|
f->fmt.pix.width &= ~0x03;
|
2016-02-15 02:51:37 +07:00
|
|
|
if (fmt->planar)
|
|
|
|
f->fmt.pix.bytesperline = f->fmt.pix.width;
|
|
|
|
else
|
|
|
|
f->fmt.pix.bytesperline =
|
|
|
|
(f->fmt.pix.width * fmt->depth) / 8;
|
2007-12-08 03:34:48 +07:00
|
|
|
f->fmt.pix.sizeimage =
|
2016-02-15 02:51:37 +07:00
|
|
|
(f->fmt.pix.height * f->fmt.pix.width * fmt->depth) / 8;
|
2013-05-31 21:48:50 +07:00
|
|
|
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_try_fmt_vid_overlay(struct file *file, void *priv,
|
2007-12-08 03:34:48 +07:00
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:34:48 +07:00
|
|
|
|
|
|
|
if (saa7134_no_overlay > 0) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 16:46:34 +07:00
|
|
|
pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2013-05-31 21:48:50 +07:00
|
|
|
if (f->fmt.win.clips == NULL)
|
|
|
|
f->fmt.win.clipcount = 0;
|
|
|
|
return verify_preview(dev, &f->fmt.win, true);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_s_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-08 03:09:53 +07:00
|
|
|
struct v4l2_format *f)
|
2007-12-08 03:34:48 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:34:48 +07:00
|
|
|
int err;
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
err = saa7134_try_fmt_vid_cap(file, priv, f);
|
2007-12-08 03:34:48 +07:00
|
|
|
if (0 != err)
|
|
|
|
return err;
|
|
|
|
|
2014-04-17 13:48:50 +07:00
|
|
|
dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
|
|
|
|
dev->width = f->fmt.pix.width;
|
|
|
|
dev->height = f->fmt.pix.height;
|
2014-04-17 17:30:53 +07:00
|
|
|
dev->field = f->fmt.pix.field;
|
2007-12-08 03:34:48 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv,
|
2007-12-08 03:34:48 +07:00
|
|
|
struct v4l2_format *f)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
int err;
|
2008-05-07 10:42:29 +07:00
|
|
|
unsigned long flags;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
if (saa7134_no_overlay > 0) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 16:46:34 +07:00
|
|
|
pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
|
2007-12-08 03:34:48 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2013-05-31 21:48:50 +07:00
|
|
|
if (f->fmt.win.clips == NULL)
|
|
|
|
f->fmt.win.clipcount = 0;
|
|
|
|
err = verify_preview(dev, &f->fmt.win, true);
|
2007-12-08 03:34:48 +07:00
|
|
|
if (0 != err)
|
|
|
|
return err;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-05-31 18:22:24 +07:00
|
|
|
dev->win = f->fmt.win;
|
|
|
|
dev->nclips = f->fmt.win.clipcount;
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2013-05-31 18:22:24 +07:00
|
|
|
if (copy_from_user(dev->clips, f->fmt.win.clips,
|
2014-04-17 17:30:53 +07:00
|
|
|
sizeof(struct v4l2_clip) * dev->nclips))
|
2007-12-08 03:34:48 +07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
if (priv == dev->overlay_owner) {
|
2007-12-08 03:34:48 +07:00
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
2013-12-14 18:28:24 +07:00
|
|
|
stop_preview(dev);
|
|
|
|
start_preview(dev);
|
2007-12-08 03:34:48 +07:00
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:09:53 +07:00
|
|
|
unsigned int n;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
n = i->index;
|
|
|
|
if (n >= SAA7134_INPUT_MAX)
|
|
|
|
return -EINVAL;
|
2016-02-05 19:24:37 +07:00
|
|
|
if (card_in(dev, i->index).type == SAA7134_NO_INPUT)
|
2007-12-08 03:09:53 +07:00
|
|
|
return -EINVAL;
|
|
|
|
i->index = n;
|
2018-09-11 03:20:42 +07:00
|
|
|
strscpy(i->name, saa7134_input_name[card_in(dev, n).type],
|
|
|
|
sizeof(i->name));
|
2016-02-05 19:37:18 +07:00
|
|
|
switch (card_in(dev, n).type) {
|
|
|
|
case SAA7134_INPUT_TV:
|
|
|
|
case SAA7134_INPUT_TV_MONO:
|
2007-12-08 03:09:53 +07:00
|
|
|
i->type = V4L2_INPUT_TYPE_TUNER;
|
2016-02-05 19:37:18 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
i->type = V4L2_INPUT_TYPE_CAMERA;
|
|
|
|
break;
|
|
|
|
}
|
2007-12-08 03:09:53 +07:00
|
|
|
if (n == dev->ctl_input) {
|
|
|
|
int v1 = saa_readb(SAA7134_STATUS_VIDEO1);
|
|
|
|
int v2 = saa_readb(SAA7134_STATUS_VIDEO2);
|
|
|
|
|
|
|
|
if (0 != (v1 & 0x40))
|
|
|
|
i->status |= V4L2_IN_ST_NO_H_LOCK;
|
|
|
|
if (0 != (v2 & 0x40))
|
2013-12-14 18:28:29 +07:00
|
|
|
i->status |= V4L2_IN_ST_NO_SIGNAL;
|
2007-12-08 03:09:53 +07:00
|
|
|
if (0 != (v2 & 0x0e))
|
|
|
|
i->status |= V4L2_IN_ST_MACROVISION;
|
|
|
|
}
|
2007-12-08 03:34:48 +07:00
|
|
|
i->std = SAA7134_NORMS;
|
2007-12-08 03:09:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_enum_input);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_g_input(struct file *file, void *priv, unsigned int *i)
|
2007-12-08 03:23:38 +07:00
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:23:38 +07:00
|
|
|
|
|
|
|
*i = dev->ctl_input;
|
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_g_input);
|
2007-12-08 03:23:38 +07:00
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_s_input(struct file *file, void *priv, unsigned int i)
|
2007-12-08 03:23:38 +07:00
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:23:38 +07:00
|
|
|
|
2009-07-03 02:09:25 +07:00
|
|
|
if (i >= SAA7134_INPUT_MAX)
|
2007-12-08 03:23:38 +07:00
|
|
|
return -EINVAL;
|
2016-02-05 19:24:37 +07:00
|
|
|
if (card_in(dev, i).type == SAA7134_NO_INPUT)
|
2007-12-08 03:23:38 +07:00
|
|
|
return -EINVAL;
|
|
|
|
video_mux(dev, i);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_s_input);
|
2007-12-08 03:23:38 +07:00
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_querycap(struct file *file, void *priv,
|
2007-12-08 03:09:53 +07:00
|
|
|
struct v4l2_capability *cap)
|
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2013-02-02 06:01:14 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
|
|
|
u32 radio_caps, video_caps, vbi_caps;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
unsigned int tuner_type = dev->tuner_type;
|
|
|
|
|
2018-09-11 03:20:42 +07:00
|
|
|
strscpy(cap->driver, "saa7134", sizeof(cap->driver));
|
2018-09-10 19:19:14 +07:00
|
|
|
strscpy(cap->card, saa7134_boards[dev->board].name,
|
2007-12-08 03:09:53 +07:00
|
|
|
sizeof(cap->card));
|
|
|
|
sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
|
2013-02-02 06:01:14 +07:00
|
|
|
|
|
|
|
cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
|
|
|
|
if ((tuner_type != TUNER_ABSENT) && (tuner_type != UNSET))
|
|
|
|
cap->device_caps |= V4L2_CAP_TUNER;
|
|
|
|
|
|
|
|
radio_caps = V4L2_CAP_RADIO;
|
2009-06-20 16:09:52 +07:00
|
|
|
if (dev->has_rds)
|
2013-02-02 06:01:14 +07:00
|
|
|
radio_caps |= V4L2_CAP_RDS_CAPTURE;
|
|
|
|
|
|
|
|
video_caps = V4L2_CAP_VIDEO_CAPTURE;
|
2014-04-17 17:30:53 +07:00
|
|
|
if (saa7134_no_overlay <= 0 && !is_empress(file))
|
2013-02-02 06:01:14 +07:00
|
|
|
video_caps |= V4L2_CAP_VIDEO_OVERLAY;
|
|
|
|
|
|
|
|
vbi_caps = V4L2_CAP_VBI_CAPTURE;
|
|
|
|
|
|
|
|
switch (vdev->vfl_type) {
|
|
|
|
case VFL_TYPE_RADIO:
|
|
|
|
cap->device_caps |= radio_caps;
|
|
|
|
break;
|
|
|
|
case VFL_TYPE_GRABBER:
|
|
|
|
cap->device_caps |= video_caps;
|
|
|
|
break;
|
|
|
|
case VFL_TYPE_VBI:
|
|
|
|
cap->device_caps |= vbi_caps;
|
|
|
|
break;
|
2017-09-29 05:39:32 +07:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
2013-02-02 06:01:14 +07:00
|
|
|
}
|
|
|
|
cap->capabilities = radio_caps | video_caps | vbi_caps |
|
|
|
|
cap->device_caps | V4L2_CAP_DEVICE_CAPS;
|
|
|
|
if (vdev->vfl_type == VFL_TYPE_RADIO) {
|
|
|
|
cap->device_caps &= ~V4L2_CAP_STREAMING;
|
|
|
|
if (!dev->has_rds)
|
|
|
|
cap->device_caps &= ~V4L2_CAP_READWRITE;
|
|
|
|
}
|
2007-12-08 03:09:53 +07:00
|
|
|
|
2010-08-06 03:22:44 +07:00
|
|
|
return 0;
|
2007-12-08 03:09:53 +07:00
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_querycap);
|
2005-11-09 12:36:35 +07:00
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id)
|
2007-12-08 03:09:53 +07:00
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2014-04-17 17:30:53 +07:00
|
|
|
struct v4l2_fh *fh = priv;
|
2007-12-08 03:09:53 +07:00
|
|
|
unsigned long flags;
|
|
|
|
unsigned int i;
|
|
|
|
v4l2_std_id fixup;
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
if (is_empress(file) && dev->overlay_owner) {
|
2008-09-06 16:34:44 +07:00
|
|
|
/* Don't change the std from the mpeg device
|
|
|
|
if overlay is active. */
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
2005-11-09 12:36:35 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
for (i = 0; i < TVNORMS; i++)
|
2013-03-15 16:10:40 +07:00
|
|
|
if (id == tvnorms[i].id)
|
2007-12-08 03:09:53 +07:00
|
|
|
break;
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
if (i == TVNORMS)
|
|
|
|
for (i = 0; i < TVNORMS; i++)
|
2013-03-15 16:10:40 +07:00
|
|
|
if (id & tvnorms[i].id)
|
2007-12-08 03:09:53 +07:00
|
|
|
break;
|
|
|
|
if (i == TVNORMS)
|
|
|
|
return -EINVAL;
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2013-03-15 16:10:40 +07:00
|
|
|
if ((id & V4L2_STD_SECAM) && (secam[0] != '-')) {
|
2007-12-08 03:09:53 +07:00
|
|
|
if (secam[0] == 'L' || secam[0] == 'l') {
|
|
|
|
if (secam[1] == 'C' || secam[1] == 'c')
|
|
|
|
fixup = V4L2_STD_SECAM_LC;
|
|
|
|
else
|
|
|
|
fixup = V4L2_STD_SECAM_L;
|
|
|
|
} else {
|
|
|
|
if (secam[0] == 'D' || secam[0] == 'd')
|
|
|
|
fixup = V4L2_STD_SECAM_DK;
|
|
|
|
else
|
|
|
|
fixup = V4L2_STD_SECAM;
|
|
|
|
}
|
2010-10-05 02:28:01 +07:00
|
|
|
for (i = 0; i < TVNORMS; i++) {
|
2007-12-08 03:09:53 +07:00
|
|
|
if (fixup == tvnorms[i].id)
|
|
|
|
break;
|
2010-10-05 02:28:01 +07:00
|
|
|
}
|
|
|
|
if (i == TVNORMS)
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2013-03-15 16:10:40 +07:00
|
|
|
id = tvnorms[i].id;
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
if (!is_empress(file) && fh == dev->overlay_owner) {
|
2007-12-08 03:09:53 +07:00
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
2013-12-14 18:28:24 +07:00
|
|
|
stop_preview(dev);
|
2007-12-08 03:09:53 +07:00
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
|
|
|
|
|
|
|
set_tvnorm(dev, &tvnorms[i]);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
2013-12-14 18:28:24 +07:00
|
|
|
start_preview(dev);
|
2007-12-08 03:09:53 +07:00
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
|
|
|
} else
|
|
|
|
set_tvnorm(dev, &tvnorms[i]);
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
saa7134_tvaudio_do_scan(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_s_std);
|
2008-09-06 16:34:44 +07:00
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id)
|
2008-09-06 16:34:44 +07:00
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2008-09-06 16:34:44 +07:00
|
|
|
|
|
|
|
*id = dev->tvnorm->id;
|
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_g_std);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-01 19:28:17 +07:00
|
|
|
static v4l2_std_id saa7134_read_std(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
static v4l2_std_id stds[] = {
|
|
|
|
V4L2_STD_UNKNOWN,
|
|
|
|
V4L2_STD_NTSC,
|
|
|
|
V4L2_STD_PAL,
|
|
|
|
V4L2_STD_SECAM };
|
|
|
|
|
|
|
|
v4l2_std_id result = 0;
|
|
|
|
|
|
|
|
u8 st1 = saa_readb(SAA7134_STATUS_VIDEO1);
|
|
|
|
u8 st2 = saa_readb(SAA7134_STATUS_VIDEO2);
|
|
|
|
|
|
|
|
if (!(st2 & 0x1)) /* RDCAP == 0 */
|
|
|
|
result = V4L2_STD_UNKNOWN;
|
|
|
|
else
|
|
|
|
result = stds[st1 & 0x03];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int saa7134_querystd(struct file *file, void *priv, v4l2_std_id *std)
|
|
|
|
{
|
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
|
|
|
*std &= saa7134_read_std(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(saa7134_querystd);
|
|
|
|
|
2007-12-11 21:51:53 +07:00
|
|
|
static int saa7134_cropcap(struct file *file, void *priv,
|
2007-12-08 03:09:53 +07:00
|
|
|
struct v4l2_cropcap *cap)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
if (cap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
|
|
|
|
cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
|
|
|
|
return -EINVAL;
|
|
|
|
cap->pixelaspect.numerator = 1;
|
|
|
|
cap->pixelaspect.denominator = 1;
|
|
|
|
if (dev->tvnorm->id & V4L2_STD_525_60) {
|
|
|
|
cap->pixelaspect.numerator = 11;
|
|
|
|
cap->pixelaspect.denominator = 10;
|
|
|
|
}
|
|
|
|
if (dev->tvnorm->id & V4L2_STD_625_50) {
|
|
|
|
cap->pixelaspect.numerator = 54;
|
|
|
|
cap->pixelaspect.denominator = 59;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-12-08 03:09:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-07-03 17:39:00 +07:00
|
|
|
static int saa7134_g_selection(struct file *file, void *f, struct v4l2_selection *sel)
|
2007-12-08 03:23:38 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:23:38 +07:00
|
|
|
|
2016-07-03 17:39:00 +07:00
|
|
|
if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
|
|
|
|
sel->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
|
2007-12-08 03:23:38 +07:00
|
|
|
return -EINVAL;
|
2016-07-03 17:39:00 +07:00
|
|
|
|
|
|
|
switch (sel->target) {
|
|
|
|
case V4L2_SEL_TGT_CROP:
|
|
|
|
sel->r = dev->crop_current;
|
|
|
|
break;
|
|
|
|
case V4L2_SEL_TGT_CROP_DEFAULT:
|
|
|
|
sel->r = dev->crop_defrect;
|
|
|
|
break;
|
|
|
|
case V4L2_SEL_TGT_CROP_BOUNDS:
|
|
|
|
sel->r = dev->crop_bounds;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2007-12-08 03:23:38 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-03 17:39:00 +07:00
|
|
|
static int saa7134_s_selection(struct file *file, void *f, struct v4l2_selection *sel)
|
2007-12-08 03:23:38 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:23:38 +07:00
|
|
|
struct v4l2_rect *b = &dev->crop_bounds;
|
2012-09-05 15:10:48 +07:00
|
|
|
struct v4l2_rect *c = &dev->crop_current;
|
2007-12-08 03:23:38 +07:00
|
|
|
|
2016-07-03 17:39:00 +07:00
|
|
|
if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
|
|
|
|
sel->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (sel->target != V4L2_SEL_TGT_CROP)
|
2007-12-08 03:23:38 +07:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
if (dev->overlay_owner)
|
2007-12-08 03:23:38 +07:00
|
|
|
return -EBUSY;
|
2014-04-17 17:30:53 +07:00
|
|
|
if (vb2_is_streaming(&dev->video_vbq))
|
2007-12-08 03:23:38 +07:00
|
|
|
return -EBUSY;
|
|
|
|
|
2016-07-03 17:39:00 +07:00
|
|
|
*c = sel->r;
|
2012-09-05 15:10:48 +07:00
|
|
|
if (c->top < b->top)
|
|
|
|
c->top = b->top;
|
|
|
|
if (c->top > b->top + b->height)
|
|
|
|
c->top = b->top + b->height;
|
|
|
|
if (c->height > b->top - c->top + b->height)
|
|
|
|
c->height = b->top - c->top + b->height;
|
|
|
|
|
|
|
|
if (c->left < b->left)
|
|
|
|
c->left = b->left;
|
|
|
|
if (c->left > b->left + b->width)
|
|
|
|
c->left = b->left + b->width;
|
|
|
|
if (c->width > b->left - c->left + b->width)
|
|
|
|
c->width = b->left - c->left + b->width;
|
2016-07-03 17:39:00 +07:00
|
|
|
sel->r = *c;
|
2007-12-08 03:23:38 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_g_tuner(struct file *file, void *priv,
|
2007-12-08 03:09:53 +07:00
|
|
|
struct v4l2_tuner *t)
|
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:09:53 +07:00
|
|
|
int n;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
if (0 != t->index)
|
|
|
|
return -EINVAL;
|
|
|
|
memset(t, 0, sizeof(*t));
|
2010-10-05 02:28:01 +07:00
|
|
|
for (n = 0; n < SAA7134_INPUT_MAX; n++) {
|
2016-02-05 19:37:18 +07:00
|
|
|
if (card_in(dev, n).type == SAA7134_INPUT_TV ||
|
|
|
|
card_in(dev, n).type == SAA7134_INPUT_TV_MONO)
|
2007-12-08 03:09:53 +07:00
|
|
|
break;
|
2010-10-05 02:28:01 +07:00
|
|
|
}
|
|
|
|
if (n == SAA7134_INPUT_MAX)
|
|
|
|
return -EINVAL;
|
2016-02-05 19:24:37 +07:00
|
|
|
if (card_in(dev, n).type != SAA7134_NO_INPUT) {
|
2018-09-11 03:20:42 +07:00
|
|
|
strscpy(t->name, "Television", sizeof(t->name));
|
2007-12-08 03:09:53 +07:00
|
|
|
t->type = V4L2_TUNER_ANALOG_TV;
|
2013-02-02 06:01:18 +07:00
|
|
|
saa_call_all(dev, tuner, g_tuner, t);
|
2007-12-08 03:09:53 +07:00
|
|
|
t->capability = V4L2_TUNER_CAP_NORM |
|
|
|
|
V4L2_TUNER_CAP_STEREO |
|
|
|
|
V4L2_TUNER_CAP_LANG1 |
|
|
|
|
V4L2_TUNER_CAP_LANG2;
|
|
|
|
t->rxsubchans = saa7134_tvaudio_getstereo(dev);
|
|
|
|
t->audmode = saa7134_tvaudio_rx2mode(t->rxsubchans);
|
|
|
|
}
|
|
|
|
if (0 != (saa_readb(SAA7134_STATUS_VIDEO1) & 0x03))
|
|
|
|
t->signal = 0xffff;
|
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_g_tuner);
|
2007-09-28 06:34:15 +07:00
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_s_tuner(struct file *file, void *priv,
|
2013-03-15 16:10:06 +07:00
|
|
|
const struct v4l2_tuner *t)
|
2007-12-08 03:09:53 +07:00
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2013-02-02 06:01:16 +07:00
|
|
|
int rx, mode;
|
2007-09-28 06:34:15 +07:00
|
|
|
|
2013-02-02 06:01:18 +07:00
|
|
|
if (0 != t->index)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
mode = dev->thread.mode;
|
|
|
|
if (UNSET == mode) {
|
|
|
|
rx = saa7134_tvaudio_getstereo(dev);
|
2012-05-14 20:17:35 +07:00
|
|
|
mode = saa7134_tvaudio_rx2mode(rx);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-12-08 03:09:53 +07:00
|
|
|
if (mode != t->audmode)
|
|
|
|
dev->thread.mode = t->audmode;
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_s_tuner);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_g_frequency(struct file *file, void *priv,
|
2007-12-08 03:09:53 +07:00
|
|
|
struct v4l2_frequency *f)
|
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-02-02 06:01:17 +07:00
|
|
|
if (0 != f->tuner)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
saa_call_all(dev, tuner, g_frequency, f);
|
2007-12-08 03:34:48 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_g_frequency);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-12-14 18:28:25 +07:00
|
|
|
int saa7134_s_frequency(struct file *file, void *priv,
|
2013-03-19 14:09:26 +07:00
|
|
|
const struct v4l2_frequency *f)
|
2007-12-08 03:09:53 +07:00
|
|
|
{
|
2013-12-14 18:28:25 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
if (0 != f->tuner)
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-01-17 22:17:14 +07:00
|
|
|
saa_call_all(dev, tuner, s_frequency, f);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
saa7134_tvaudio_do_scan(dev);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-12-14 18:28:25 +07:00
|
|
|
EXPORT_SYMBOL_GPL(saa7134_s_frequency);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_enum_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-08 03:23:38 +07:00
|
|
|
struct v4l2_fmtdesc *f)
|
2007-12-08 03:09:53 +07:00
|
|
|
{
|
2007-12-08 03:34:48 +07:00
|
|
|
if (f->index >= FORMATS)
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2018-09-10 19:19:14 +07:00
|
|
|
strscpy(f->description, formats[f->index].name,
|
2007-12-08 03:34:48 +07:00
|
|
|
sizeof(f->description));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
f->pixelformat = formats[f->index].fourcc;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:34:48 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int saa7134_enum_fmt_vid_overlay(struct file *file, void *priv,
|
2007-12-08 03:34:48 +07:00
|
|
|
struct v4l2_fmtdesc *f)
|
|
|
|
{
|
|
|
|
if (saa7134_no_overlay > 0) {
|
[media] saa7134: instead of using printk KERN_foo, use pr_foo
Replaces all occurrences of printk with KERN_INFO, KERN_WARNING
and KERN_ERR to pr_info/pr_warning, pr_err, using this small
shell script:
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_INFO ','pr_info(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_ERR ','pr_err(',g <$i >a && mv a $i; done
for i in drivers/media/pci/saa7134/*.[ch]; do sed s,'printk(KERN_WARNING ','pr_warn(',g <$i >a && mv a $i; done
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-04-30 16:46:34 +07:00
|
|
|
pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
|
2007-12-08 03:23:38 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2007-12-08 03:34:48 +07:00
|
|
|
|
|
|
|
if ((f->index >= FORMATS) || formats[f->index].planar)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-09-10 19:19:14 +07:00
|
|
|
strscpy(f->description, formats[f->index].name,
|
2007-12-08 03:34:48 +07:00
|
|
|
sizeof(f->description));
|
|
|
|
|
|
|
|
f->pixelformat = formats[f->index].fourcc;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-12-11 21:51:53 +07:00
|
|
|
static int saa7134_g_fbuf(struct file *file, void *f,
|
2007-12-08 03:09:53 +07:00
|
|
|
struct v4l2_framebuffer *fb)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
*fb = dev->ovbuf;
|
|
|
|
fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING;
|
2006-03-18 06:54:32 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-11 21:51:53 +07:00
|
|
|
static int saa7134_s_fbuf(struct file *file, void *f,
|
2012-09-04 20:26:45 +07:00
|
|
|
const struct v4l2_framebuffer *fb)
|
2007-12-08 03:09:53 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:09:53 +07:00
|
|
|
struct saa7134_format *fmt;
|
|
|
|
|
|
|
|
if (!capable(CAP_SYS_ADMIN) &&
|
|
|
|
!capable(CAP_SYS_RAWIO))
|
|
|
|
return -EPERM;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
/* check args */
|
|
|
|
fmt = format_by_fourcc(fb->fmt.pixelformat);
|
|
|
|
if (NULL == fmt)
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
/* ok, accept it */
|
|
|
|
dev->ovbuf = *fb;
|
|
|
|
dev->ovfmt = fmt;
|
|
|
|
if (0 == dev->ovbuf.fmt.bytesperline)
|
|
|
|
dev->ovbuf.fmt.bytesperline =
|
|
|
|
dev->ovbuf.fmt.width*fmt->depth/8;
|
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-12-14 18:28:26 +07:00
|
|
|
static int saa7134_overlay(struct file *file, void *priv, unsigned int on)
|
2007-12-08 03:09:53 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-08 03:09:53 +07:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (on) {
|
|
|
|
if (saa7134_no_overlay > 0) {
|
2015-04-30 18:52:35 +07:00
|
|
|
video_dbg("no_overlay\n");
|
2007-12-08 03:09:53 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
if (dev->overlay_owner && priv != dev->overlay_owner)
|
2005-04-17 05:20:36 +07:00
|
|
|
return -EBUSY;
|
2014-04-17 17:30:53 +07:00
|
|
|
dev->overlay_owner = priv;
|
2007-12-08 03:09:53 +07:00
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
2013-12-14 18:28:24 +07:00
|
|
|
start_preview(dev);
|
2007-12-08 03:09:53 +07:00
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-12-08 03:09:53 +07:00
|
|
|
if (!on) {
|
2014-04-17 17:30:53 +07:00
|
|
|
if (priv != dev->overlay_owner)
|
2007-12-08 03:09:53 +07:00
|
|
|
return -EINVAL;
|
|
|
|
spin_lock_irqsave(&dev->slock, flags);
|
2013-12-14 18:28:24 +07:00
|
|
|
stop_preview(dev);
|
2007-12-08 03:09:53 +07:00
|
|
|
spin_unlock_irqrestore(&dev->slock, flags);
|
2014-04-17 17:30:53 +07:00
|
|
|
dev->overlay_owner = NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2007-12-08 03:09:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-16 22:31:57 +07:00
|
|
|
#ifdef CONFIG_VIDEO_ADV_DEBUG
|
|
|
|
static int vidioc_g_register (struct file *file, void *priv,
|
2008-12-30 17:14:19 +07:00
|
|
|
struct v4l2_dbg_register *reg)
|
2008-06-16 22:31:57 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2008-06-16 22:31:57 +07:00
|
|
|
|
2013-05-29 16:59:59 +07:00
|
|
|
reg->val = saa_readb(reg->reg & 0xffffff);
|
2008-12-30 17:14:19 +07:00
|
|
|
reg->size = 1;
|
2008-06-16 22:31:57 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vidioc_s_register (struct file *file, void *priv,
|
2013-03-24 18:28:46 +07:00
|
|
|
const struct v4l2_dbg_register *reg)
|
2008-06-16 22:31:57 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2008-06-16 22:31:57 +07:00
|
|
|
|
2013-05-29 16:59:59 +07:00
|
|
|
saa_writeb(reg->reg & 0xffffff, reg->val);
|
2008-06-16 22:31:57 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
static int radio_g_tuner(struct file *file, void *priv,
|
|
|
|
struct v4l2_tuner *t)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
if (0 != t->index)
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2018-09-11 03:20:42 +07:00
|
|
|
strscpy(t->name, "Radio", sizeof(t->name));
|
2007-12-08 03:09:53 +07:00
|
|
|
|
2009-01-17 22:17:14 +07:00
|
|
|
saa_call_all(dev, tuner, g_tuner, t);
|
2013-02-02 06:01:15 +07:00
|
|
|
t->audmode &= V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO;
|
2007-12-08 03:09:53 +07:00
|
|
|
if (dev->input->amux == TV) {
|
|
|
|
t->signal = 0xf800 - ((saa_readb(0x581) & 0x1f) << 11);
|
|
|
|
t->rxsubchans = (saa_readb(0x529) & 0x08) ?
|
|
|
|
V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
|
2005-06-24 12:05:09 +07:00
|
|
|
}
|
2007-12-08 03:09:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static int radio_s_tuner(struct file *file, void *priv,
|
2013-03-15 16:10:06 +07:00
|
|
|
const struct v4l2_tuner *t)
|
2007-12-08 03:09:53 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-06-24 12:05:09 +07:00
|
|
|
|
2007-12-08 03:09:53 +07:00
|
|
|
if (0 != t->index)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-01-17 22:17:14 +07:00
|
|
|
saa_call_all(dev, tuner, s_tuner, t);
|
2007-12-08 03:09:53 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2005-06-24 12:05:09 +07:00
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static const struct v4l2_file_operations video_fops =
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = video_open,
|
|
|
|
.release = video_release,
|
2014-04-17 17:30:53 +07:00
|
|
|
.read = vb2_fop_read,
|
|
|
|
.poll = vb2_fop_poll,
|
|
|
|
.mmap = vb2_fop_mmap,
|
|
|
|
.unlocked_ioctl = video_ioctl2,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2008-07-21 12:57:38 +07:00
|
|
|
static const struct v4l2_ioctl_ops video_ioctl_ops = {
|
2007-12-11 21:51:53 +07:00
|
|
|
.vidioc_querycap = saa7134_querycap,
|
2008-05-28 22:16:41 +07:00
|
|
|
.vidioc_enum_fmt_vid_cap = saa7134_enum_fmt_vid_cap,
|
|
|
|
.vidioc_g_fmt_vid_cap = saa7134_g_fmt_vid_cap,
|
|
|
|
.vidioc_try_fmt_vid_cap = saa7134_try_fmt_vid_cap,
|
|
|
|
.vidioc_s_fmt_vid_cap = saa7134_s_fmt_vid_cap,
|
|
|
|
.vidioc_enum_fmt_vid_overlay = saa7134_enum_fmt_vid_overlay,
|
|
|
|
.vidioc_g_fmt_vid_overlay = saa7134_g_fmt_vid_overlay,
|
|
|
|
.vidioc_try_fmt_vid_overlay = saa7134_try_fmt_vid_overlay,
|
|
|
|
.vidioc_s_fmt_vid_overlay = saa7134_s_fmt_vid_overlay,
|
|
|
|
.vidioc_g_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap,
|
|
|
|
.vidioc_try_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap,
|
|
|
|
.vidioc_s_fmt_vbi_cap = saa7134_try_get_set_fmt_vbi_cap,
|
2007-12-11 21:51:53 +07:00
|
|
|
.vidioc_cropcap = saa7134_cropcap,
|
2014-04-17 17:30:53 +07:00
|
|
|
.vidioc_reqbufs = vb2_ioctl_reqbufs,
|
|
|
|
.vidioc_querybuf = vb2_ioctl_querybuf,
|
|
|
|
.vidioc_qbuf = vb2_ioctl_qbuf,
|
|
|
|
.vidioc_dqbuf = vb2_ioctl_dqbuf,
|
2015-12-14 17:17:00 +07:00
|
|
|
.vidioc_expbuf = vb2_ioctl_expbuf,
|
2007-12-11 21:51:53 +07:00
|
|
|
.vidioc_s_std = saa7134_s_std,
|
2008-09-06 16:34:44 +07:00
|
|
|
.vidioc_g_std = saa7134_g_std,
|
2014-04-01 19:28:17 +07:00
|
|
|
.vidioc_querystd = saa7134_querystd,
|
2007-12-11 21:51:53 +07:00
|
|
|
.vidioc_enum_input = saa7134_enum_input,
|
|
|
|
.vidioc_g_input = saa7134_g_input,
|
|
|
|
.vidioc_s_input = saa7134_s_input,
|
2014-04-17 17:30:53 +07:00
|
|
|
.vidioc_streamon = vb2_ioctl_streamon,
|
|
|
|
.vidioc_streamoff = vb2_ioctl_streamoff,
|
2007-12-11 21:51:53 +07:00
|
|
|
.vidioc_g_tuner = saa7134_g_tuner,
|
|
|
|
.vidioc_s_tuner = saa7134_s_tuner,
|
2016-07-03 17:39:00 +07:00
|
|
|
.vidioc_g_selection = saa7134_g_selection,
|
|
|
|
.vidioc_s_selection = saa7134_s_selection,
|
2007-12-11 21:51:53 +07:00
|
|
|
.vidioc_g_fbuf = saa7134_g_fbuf,
|
|
|
|
.vidioc_s_fbuf = saa7134_s_fbuf,
|
|
|
|
.vidioc_overlay = saa7134_overlay,
|
|
|
|
.vidioc_g_frequency = saa7134_g_frequency,
|
|
|
|
.vidioc_s_frequency = saa7134_s_frequency,
|
2008-06-16 22:31:57 +07:00
|
|
|
#ifdef CONFIG_VIDEO_ADV_DEBUG
|
|
|
|
.vidioc_g_register = vidioc_g_register,
|
|
|
|
.vidioc_s_register = vidioc_s_register,
|
|
|
|
#endif
|
2013-12-14 18:28:28 +07:00
|
|
|
.vidioc_log_status = v4l2_ctrl_log_status,
|
|
|
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
|
|
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static const struct v4l2_file_operations radio_fops = {
|
2008-07-21 12:57:38 +07:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = video_open,
|
2009-03-29 16:26:27 +07:00
|
|
|
.read = radio_read,
|
2008-07-21 12:57:38 +07:00
|
|
|
.release = video_release,
|
2014-04-17 17:30:53 +07:00
|
|
|
.unlocked_ioctl = video_ioctl2,
|
2009-03-29 16:26:27 +07:00
|
|
|
.poll = radio_poll,
|
2008-07-21 12:57:38 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ioctl_ops radio_ioctl_ops = {
|
2013-02-02 06:01:14 +07:00
|
|
|
.vidioc_querycap = saa7134_querycap,
|
2007-12-08 03:09:53 +07:00
|
|
|
.vidioc_g_tuner = radio_g_tuner,
|
|
|
|
.vidioc_s_tuner = radio_s_tuner,
|
2007-12-11 21:51:53 +07:00
|
|
|
.vidioc_g_frequency = saa7134_g_frequency,
|
|
|
|
.vidioc_s_frequency = saa7134_s_frequency,
|
2013-12-14 18:28:28 +07:00
|
|
|
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
|
|
|
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2008-07-21 12:57:38 +07:00
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
/* exported stuff */
|
|
|
|
|
|
|
|
struct video_device saa7134_video_template = {
|
|
|
|
.name = "saa7134-video",
|
|
|
|
.fops = &video_fops,
|
2018-01-05 01:08:56 +07:00
|
|
|
.ioctl_ops = &video_ioctl_ops,
|
2008-07-21 12:57:38 +07:00
|
|
|
.tvnorms = SAA7134_NORMS,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct video_device saa7134_radio_template = {
|
|
|
|
.name = "saa7134-radio",
|
|
|
|
.fops = &radio_fops,
|
2018-01-05 01:08:56 +07:00
|
|
|
.ioctl_ops = &radio_ioctl_ops,
|
2008-07-21 12:57:38 +07:00
|
|
|
};
|
|
|
|
|
2013-12-14 18:28:24 +07:00
|
|
|
static const struct v4l2_ctrl_ops saa7134_ctrl_ops = {
|
|
|
|
.s_ctrl = saa7134_s_ctrl,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config saa7134_ctrl_invert = {
|
|
|
|
.ops = &saa7134_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_INVERT,
|
|
|
|
.name = "Invert",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.min = 0,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config saa7134_ctrl_y_odd = {
|
|
|
|
.ops = &saa7134_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_Y_ODD,
|
|
|
|
.name = "Y Offset Odd Field",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.min = 0,
|
|
|
|
.max = 128,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config saa7134_ctrl_y_even = {
|
|
|
|
.ops = &saa7134_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_Y_EVEN,
|
|
|
|
.name = "Y Offset Even Field",
|
|
|
|
.type = V4L2_CTRL_TYPE_INTEGER,
|
|
|
|
.min = 0,
|
|
|
|
.max = 128,
|
|
|
|
.step = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct v4l2_ctrl_config saa7134_ctrl_automute = {
|
|
|
|
.ops = &saa7134_ctrl_ops,
|
|
|
|
.id = V4L2_CID_PRIVATE_AUTOMUTE,
|
|
|
|
.name = "Automute",
|
|
|
|
.type = V4L2_CTRL_TYPE_BOOLEAN,
|
|
|
|
.min = 0,
|
|
|
|
.max = 1,
|
|
|
|
.step = 1,
|
|
|
|
.def = 1,
|
|
|
|
};
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
int saa7134_video_init1(struct saa7134_dev *dev)
|
|
|
|
{
|
2013-12-14 18:28:24 +07:00
|
|
|
struct v4l2_ctrl_handler *hdl = &dev->ctrl_handler;
|
2014-04-17 17:30:53 +07:00
|
|
|
struct vb2_queue *q;
|
|
|
|
int ret;
|
2013-12-14 18:28:24 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* sanitycheck insmod options */
|
|
|
|
if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME)
|
|
|
|
gbuffers = 2;
|
2012-10-28 02:20:27 +07:00
|
|
|
if (gbufsize > gbufsize_max)
|
2005-04-17 05:20:36 +07:00
|
|
|
gbufsize = gbufsize_max;
|
|
|
|
gbufsize = (gbufsize + PAGE_SIZE - 1) & PAGE_MASK;
|
|
|
|
|
2013-12-14 18:28:24 +07:00
|
|
|
v4l2_ctrl_handler_init(hdl, 11);
|
|
|
|
v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops,
|
|
|
|
V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
|
|
|
|
v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops,
|
|
|
|
V4L2_CID_CONTRAST, 0, 127, 1, 68);
|
|
|
|
v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops,
|
|
|
|
V4L2_CID_SATURATION, 0, 127, 1, 64);
|
|
|
|
v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops,
|
|
|
|
V4L2_CID_HUE, -128, 127, 1, 0);
|
|
|
|
v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops,
|
|
|
|
V4L2_CID_HFLIP, 0, 1, 1, 0);
|
|
|
|
v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops,
|
|
|
|
V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
|
|
|
|
v4l2_ctrl_new_std(hdl, &saa7134_ctrl_ops,
|
|
|
|
V4L2_CID_AUDIO_VOLUME, -15, 15, 1, 0);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &saa7134_ctrl_invert, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &saa7134_ctrl_y_odd, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &saa7134_ctrl_y_even, NULL);
|
|
|
|
v4l2_ctrl_new_custom(hdl, &saa7134_ctrl_automute, NULL);
|
|
|
|
if (hdl->error)
|
|
|
|
return hdl->error;
|
|
|
|
if (card_has_radio(dev)) {
|
|
|
|
hdl = &dev->radio_ctrl_handler;
|
|
|
|
v4l2_ctrl_handler_init(hdl, 2);
|
|
|
|
v4l2_ctrl_add_handler(hdl, &dev->ctrl_handler,
|
2018-05-21 15:54:36 +07:00
|
|
|
v4l2_ctrl_radio_filter, false);
|
2013-12-14 18:28:24 +07:00
|
|
|
if (hdl->error)
|
|
|
|
return hdl->error;
|
|
|
|
}
|
|
|
|
dev->ctl_mute = 1;
|
|
|
|
|
|
|
|
if (dev->tda9887_conf && saa7134_ctrl_automute.def)
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->tda9887_conf |= TDA9887_AUTOMUTE;
|
|
|
|
dev->automute = 0;
|
|
|
|
|
2005-11-09 12:37:43 +07:00
|
|
|
INIT_LIST_HEAD(&dev->video_q.queue);
|
2017-10-17 06:11:30 +07:00
|
|
|
timer_setup(&dev->video_q.timeout, saa7134_buffer_timeout, 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->video_q.dev = dev;
|
2013-05-31 18:30:49 +07:00
|
|
|
dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
|
|
|
|
dev->width = 720;
|
|
|
|
dev->height = 576;
|
2014-04-17 17:30:53 +07:00
|
|
|
dev->field = V4L2_FIELD_INTERLACED;
|
2013-05-31 21:48:50 +07:00
|
|
|
dev->win.w.width = dev->width;
|
|
|
|
dev->win.w.height = dev->height;
|
|
|
|
dev->win.field = V4L2_FIELD_INTERLACED;
|
|
|
|
dev->ovbuf.fmt.width = dev->width;
|
|
|
|
dev->ovbuf.fmt.height = dev->height;
|
|
|
|
dev->ovbuf.fmt.pixelformat = dev->fmt->fourcc;
|
|
|
|
dev->ovbuf.fmt.colorspace = V4L2_COLORSPACE_SMPTE170M;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-09-28 06:34:25 +07:00
|
|
|
if (saa7134_boards[dev->board].video_out)
|
|
|
|
saa7134_videoport_init(dev);
|
|
|
|
|
2014-04-17 17:30:53 +07:00
|
|
|
q = &dev->video_vbq;
|
|
|
|
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
|
|
/*
|
2014-04-17 16:44:31 +07:00
|
|
|
* Do not add VB2_USERPTR unless explicitly requested: the saa7134 DMA
|
|
|
|
* engine cannot handle transfers that do not start at the beginning
|
|
|
|
* of a page. A user-provided pointer can start anywhere in a page, so
|
|
|
|
* USERPTR support is a no-go unless the application knows about these
|
|
|
|
* limitations and has special support for this.
|
2014-04-17 17:30:53 +07:00
|
|
|
*/
|
2015-12-14 17:17:00 +07:00
|
|
|
q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
|
2014-04-17 16:44:31 +07:00
|
|
|
if (saa7134_userptr)
|
|
|
|
q->io_modes |= VB2_USERPTR;
|
2014-04-17 17:30:53 +07:00
|
|
|
q->drv_priv = &dev->video_q;
|
|
|
|
q->ops = &vb2_qops;
|
|
|
|
q->gfp_flags = GFP_DMA32;
|
|
|
|
q->mem_ops = &vb2_dma_sg_memops;
|
|
|
|
q->buf_struct_size = sizeof(struct saa7134_buf);
|
|
|
|
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
|
|
|
|
q->lock = &dev->lock;
|
2016-02-15 21:37:15 +07:00
|
|
|
q->dev = &dev->pci->dev;
|
2014-04-17 17:30:53 +07:00
|
|
|
ret = vb2_queue_init(q);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2014-04-17 16:06:06 +07:00
|
|
|
saa7134_pgtable_alloc(dev->pci, &dev->video_q.pt);
|
2014-04-17 17:30:53 +07:00
|
|
|
|
|
|
|
q = &dev->vbi_vbq;
|
|
|
|
q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
|
|
|
|
/* Don't add VB2_USERPTR, see comment above */
|
|
|
|
q->io_modes = VB2_MMAP | VB2_READ;
|
2014-04-17 16:44:31 +07:00
|
|
|
if (saa7134_userptr)
|
|
|
|
q->io_modes |= VB2_USERPTR;
|
2014-04-17 17:30:53 +07:00
|
|
|
q->drv_priv = &dev->vbi_q;
|
|
|
|
q->ops = &saa7134_vbi_qops;
|
|
|
|
q->gfp_flags = GFP_DMA32;
|
|
|
|
q->mem_ops = &vb2_dma_sg_memops;
|
|
|
|
q->buf_struct_size = sizeof(struct saa7134_buf);
|
|
|
|
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
|
|
|
|
q->lock = &dev->lock;
|
2016-02-15 21:37:15 +07:00
|
|
|
q->dev = &dev->pci->dev;
|
2014-04-17 17:30:53 +07:00
|
|
|
ret = vb2_queue_init(q);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2014-04-17 16:06:06 +07:00
|
|
|
saa7134_pgtable_alloc(dev->pci, &dev->vbi_q.pt);
|
2013-12-14 18:28:23 +07:00
|
|
|
|
2007-09-28 06:34:25 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-12-14 18:28:23 +07:00
|
|
|
void saa7134_video_fini(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
/* free stuff */
|
2014-04-17 17:30:53 +07:00
|
|
|
vb2_queue_release(&dev->video_vbq);
|
2014-04-17 16:06:06 +07:00
|
|
|
saa7134_pgtable_free(dev->pci, &dev->video_q.pt);
|
2014-04-17 17:30:53 +07:00
|
|
|
vb2_queue_release(&dev->vbi_vbq);
|
2014-04-17 16:06:06 +07:00
|
|
|
saa7134_pgtable_free(dev->pci, &dev->vbi_q.pt);
|
2013-12-14 18:28:24 +07:00
|
|
|
v4l2_ctrl_handler_free(&dev->ctrl_handler);
|
|
|
|
if (card_has_radio(dev))
|
|
|
|
v4l2_ctrl_handler_free(&dev->radio_ctrl_handler);
|
2013-12-14 18:28:23 +07:00
|
|
|
}
|
|
|
|
|
2007-09-28 06:34:25 +07:00
|
|
|
int saa7134_videoport_init(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
/* enable video output */
|
|
|
|
int vo = saa7134_boards[dev->board].video_out;
|
|
|
|
int video_reg;
|
|
|
|
unsigned int vid_port_opts = saa7134_boards[dev->board].vid_port_opts;
|
2008-06-10 22:43:58 +07:00
|
|
|
|
|
|
|
/* Configure videoport */
|
2007-09-28 06:34:25 +07:00
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL0, video_out[vo][0]);
|
|
|
|
video_reg = video_out[vo][1];
|
|
|
|
if (vid_port_opts & SET_T_CODE_POLARITY_NON_INVERTED)
|
|
|
|
video_reg &= ~VP_T_CODE_P_INVERTED;
|
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL1, video_reg);
|
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL2, video_out[vo][2]);
|
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL4, video_out[vo][4]);
|
|
|
|
video_reg = video_out[vo][5];
|
|
|
|
if (vid_port_opts & SET_CLOCK_NOT_DELAYED)
|
|
|
|
video_reg &= ~VP_CLK_CTRL2_DELAYED;
|
|
|
|
if (vid_port_opts & SET_CLOCK_INVERTED)
|
|
|
|
video_reg |= VP_CLK_CTRL1_INVERTED;
|
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL5, video_reg);
|
|
|
|
video_reg = video_out[vo][6];
|
|
|
|
if (vid_port_opts & SET_VSYNC_OFF) {
|
|
|
|
video_reg &= ~VP_VS_TYPE_MASK;
|
|
|
|
video_reg |= VP_VS_TYPE_OFF;
|
|
|
|
}
|
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL6, video_reg);
|
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL7, video_out[vo][7]);
|
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL8, video_out[vo][8]);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-06-10 22:43:58 +07:00
|
|
|
/* Start videoport */
|
|
|
|
saa_writeb(SAA7134_VIDEO_PORT_CTRL3, video_out[vo][3]);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int saa7134_video_init2(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
/* init video hw */
|
|
|
|
set_tvnorm(dev,&tvnorms[0]);
|
|
|
|
video_mux(dev,0);
|
2013-12-14 18:28:24 +07:00
|
|
|
v4l2_ctrl_handler_setup(&dev->ctrl_handler);
|
2005-04-17 05:20:36 +07:00
|
|
|
saa7134_tvaudio_setmute(dev);
|
|
|
|
saa7134_tvaudio_setvolume(dev,dev->ctl_volume);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-28 06:44:39 +07:00
|
|
|
void saa7134_irq_video_signalchange(struct saa7134_dev *dev)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
static const char *st[] = {
|
|
|
|
"(no signal)", "NTSC", "PAL", "SECAM" };
|
|
|
|
u32 st1,st2;
|
|
|
|
|
|
|
|
st1 = saa_readb(SAA7134_STATUS_VIDEO1);
|
|
|
|
st2 = saa_readb(SAA7134_STATUS_VIDEO2);
|
2015-04-30 18:52:35 +07:00
|
|
|
video_dbg("DCSDT: pll: %s, sync: %s, norm: %s\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
(st1 & 0x40) ? "not locked" : "locked",
|
|
|
|
(st2 & 0x40) ? "no" : "yes",
|
|
|
|
st[st1 & 0x03]);
|
2007-09-28 06:44:39 +07:00
|
|
|
dev->nosignal = (st1 & 0x40) || (st2 & 0x40) || !(st2 & 0x1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (dev->nosignal) {
|
|
|
|
/* no video signal -> mute audio */
|
|
|
|
if (dev->ctl_automute)
|
|
|
|
dev->automute = 1;
|
|
|
|
saa7134_tvaudio_setmute(dev);
|
|
|
|
} else {
|
|
|
|
/* wake up tvaudio audio carrier scan thread */
|
|
|
|
saa7134_tvaudio_do_scan(dev);
|
|
|
|
}
|
2007-09-28 06:44:39 +07:00
|
|
|
|
|
|
|
if ((st2 & 0x80) && !noninterlaced && !dev->nosignal)
|
|
|
|
saa_clearb(SAA7134_SYNC_CTRL, 0x20);
|
|
|
|
else
|
|
|
|
saa_setb(SAA7134_SYNC_CTRL, 0x20);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (dev->mops && dev->mops->signal_change)
|
|
|
|
dev->mops->signal_change(dev);
|
|
|
|
}
|
|
|
|
|
2007-09-28 06:44:39 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
void saa7134_irq_video_done(struct saa7134_dev *dev, unsigned long status)
|
|
|
|
{
|
|
|
|
enum v4l2_field field;
|
|
|
|
|
|
|
|
spin_lock(&dev->slock);
|
|
|
|
if (dev->video_q.curr) {
|
2014-04-17 17:30:53 +07:00
|
|
|
field = dev->field;
|
2005-04-17 05:20:36 +07:00
|
|
|
if (V4L2_FIELD_HAS_BOTH(field)) {
|
|
|
|
/* make sure we have seen both fields */
|
|
|
|
if ((status & 0x10) == 0x00) {
|
|
|
|
dev->video_q.curr->top_seen = 1;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (!dev->video_q.curr->top_seen)
|
|
|
|
goto done;
|
|
|
|
} else if (field == V4L2_FIELD_TOP) {
|
|
|
|
if ((status & 0x10) != 0x10)
|
|
|
|
goto done;
|
|
|
|
} else if (field == V4L2_FIELD_BOTTOM) {
|
|
|
|
if ((status & 0x10) != 0x00)
|
|
|
|
goto done;
|
|
|
|
}
|
2014-04-17 17:30:53 +07:00
|
|
|
saa7134_buffer_finish(dev, &dev->video_q, VB2_BUF_STATE_DONE);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2014-04-17 13:48:50 +07:00
|
|
|
saa7134_buffer_next(dev, &dev->video_q);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
done:
|
|
|
|
spin_unlock(&dev->slock);
|
|
|
|
}
|