Path: blob/master/drivers/media/video/ivtv/ivtv-controls.c
17782 views
/*1ioctl control functions2Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>3Copyright (C) 2005-2007 Hans Verkuil <[email protected]>45This program is free software; you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation; either version 2 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program; if not, write to the Free Software17Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/1920#include "ivtv-driver.h"21#include "ivtv-ioctl.h"22#include "ivtv-controls.h"2324static int ivtv_s_stream_vbi_fmt(struct cx2341x_handler *cxhdl, u32 fmt)25{26struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);2728/* First try to allocate sliced VBI buffers if needed. */29if (fmt && itv->vbi.sliced_mpeg_data[0] == NULL) {30int i;3132for (i = 0; i < IVTV_VBI_FRAMES; i++) {33/* Yuck, hardcoded. Needs to be a define */34itv->vbi.sliced_mpeg_data[i] = kmalloc(2049, GFP_KERNEL);35if (itv->vbi.sliced_mpeg_data[i] == NULL) {36while (--i >= 0) {37kfree(itv->vbi.sliced_mpeg_data[i]);38itv->vbi.sliced_mpeg_data[i] = NULL;39}40return -ENOMEM;41}42}43}4445itv->vbi.insert_mpeg = fmt;4647if (itv->vbi.insert_mpeg == 0) {48return 0;49}50/* Need sliced data for mpeg insertion */51if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) {52if (itv->is_60hz)53itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525;54else55itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625;56ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz);57}58return 0;59}6061static int ivtv_s_video_encoding(struct cx2341x_handler *cxhdl, u32 val)62{63struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);64int is_mpeg1 = val == V4L2_MPEG_VIDEO_ENCODING_MPEG_1;65struct v4l2_mbus_framefmt fmt;6667/* fix videodecoder resolution */68fmt.width = cxhdl->width / (is_mpeg1 ? 2 : 1);69fmt.height = cxhdl->height;70fmt.code = V4L2_MBUS_FMT_FIXED;71v4l2_subdev_call(itv->sd_video, video, s_mbus_fmt, &fmt);72return 0;73}7475static int ivtv_s_audio_sampling_freq(struct cx2341x_handler *cxhdl, u32 idx)76{77static const u32 freqs[3] = { 44100, 48000, 32000 };78struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);7980/* The audio clock of the digitizer must match the codec sample81rate otherwise you get some very strange effects. */82if (idx < ARRAY_SIZE(freqs))83ivtv_call_all(itv, audio, s_clock_freq, freqs[idx]);84return 0;85}8687static int ivtv_s_audio_mode(struct cx2341x_handler *cxhdl, u32 val)88{89struct ivtv *itv = container_of(cxhdl, struct ivtv, cxhdl);9091itv->dualwatch_stereo_mode = val;92return 0;93}9495struct cx2341x_handler_ops ivtv_cxhdl_ops = {96.s_audio_mode = ivtv_s_audio_mode,97.s_audio_sampling_freq = ivtv_s_audio_sampling_freq,98.s_video_encoding = ivtv_s_video_encoding,99.s_stream_vbi_fmt = ivtv_s_stream_vbi_fmt,100};101102103