/*
* Video for Linux Two
*
* A generic video device interface for the LINUX operating system
* using a set of device structures/vectors for low level operations.
*
* This file replaces the videodev.c file that comes with the
* regular kernel distribution.
*
* 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.
*
* Author: Bill Dirks <bill@thedirks.org>
* based on code by Alan Cox, <alan@cymru.net>
*
*/
/*
* Video capture interface for Linux
*
* A generic video device interface for the LINUX operating system
* using a set of device structures/vectors for low level operations.
*
* 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.
*
* Author: Alan Cox, <alan@redhat.com>
*
* Fixes:
*/
/*
* Video4linux 1/2 integration by Justin Schoeman
* <justin@suntiger.ee.up.ac.za>
* 2.4 PROCFS support ported from 2.4 kernels by
* Iñaki García Etxebarria <garetxe@euskalnet.net>
* Makefile fix by "W. Michael Petullo" <mike@flyn.org>
* 2.4 devfs support ported from 2.4 kernels by
* Dan Merillat <dan@merillat.org>
* Added Gerd Knorrs v4l1 enhancements (Justin Schoeman)
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/i2c.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/pgtable.h>
#include <asm/io.h>
#include <asm/div64.h>
#include <linux/video_decoder.h>
#define __OLD_VIDIOC_ /* To allow fixing old calls*/
#include <media/v4l2-common.h>
#include <media/v4l2-chip-ident.h>
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
#endif
#include <linux/videodev.h>
MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr");
MODULE_DESCRIPTION("misc helper functions for v4l2 device drivers");
MODULE_LICENSE("GPL");
/*
*
* V 4 L 2 D R I V E R H E L P E R A P I
*
*/
/*
* Video Standard Operations (contributed by Michael Schimek)
*/
char *v4l2_norm_to_name(v4l2_std_id id)
{
char *name;
u32 myid = id;
/* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle
64 bit comparations. So, on that architecture, with some gcc variants,
compilation fails. Currently, the max value is 30bit wide.
*/
BUG_ON(myid != id);
switch (myid) {
case V4L2_STD_PAL:
name="PAL"; break;
case V4L2_STD_PAL_BG:
name="PAL-BG"; break;
case V4L2_STD_PAL_DK:
name="PAL-DK"; break;
case V4L2_STD_PAL_B:
name="PAL-B"; break;
case V4L2_STD_PAL_B1:
name="PAL-B1"; break;
case V4L2_STD_PAL_G:
name="PAL-G"; break;
case V4L2_STD_PAL_H:
name="PAL-H"; break;
case V4L2_STD_PAL_I:
name="PAL-I"; break;
case V4L2_STD_PAL_D:
name="PAL-D"; break;
case V4L2_STD_PAL_D1:
name="PAL-D1"; break;
case V4L2_STD_PAL_K:
name="PAL-K"; break;
case V4L2_STD_PAL_M:
name="PAL-M"; break;
case V4L2_STD_PAL_N:
name="PAL-N"; break;
case V4L2_STD_PAL_Nc:
name="PAL-Nc"; break;
case V4L2_STD_PAL_60:
name="PAL-60"; break;
case V4L2_STD_NTSC:
name="NTSC"; break;
case V4L2_STD_NTSC_M:
name="NTSC-M"; break;
case V4L2_STD_NTSC_M_JP:
name="NTSC-M-JP"; break;
case V4L2_STD_NTSC_443:
name="NTSC-443"; break;
case V4L2_STD_NTSC_M_KR:
name="NTSC-M-KR"; break;
case V4L2_STD_SECAM:
name="SECAM"; break;
case V4L2_STD_SECAM_DK:
name="SECAM-DK"; break;
case V4L2_STD_SECAM_B:
name="SECAM-B"; break;
case V4L2_STD_SECAM_D:
name="SECAM-D"; break;
case V4L2_STD_SECAM_G:
name="SECAM-G"; break;
case V4L2_STD_SECAM_H:
name="SECAM-H"; break;
case V4L2_STD_SECAM_K:
name="SECAM-K"; break;
case V4L2_STD_SECAM_K1:
name="SECAM-K1"; break;
case V4L2_STD_SECAM_L:
name="SECAM-L"; break;
case V4L2_STD_SECAM_LC:
name="SECAM-LC"; break;
default:
name="Unknown"; break;
}
return name;
}
/* Fill in the fields of a v4l2_standard structure according to the
'id' and 'transmission' parameters. Returns negative on error. */
int v4l2_video_std_construct(struct v4l2_standard *vs,
int id, char *name)
{
u32 index = vs->index;
memset(vs, 0, sizeof(struct v4l2_standard));
vs->index = index;
vs->id = id;
if (id & V4L2_STD_525_60) {
vs->frameperiod.numerator = 1001;
vs->frameperiod.denominator = 30000;
vs->framelines = 525;
} else {
vs->