X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=drivers%2Fmedia%2Fradio%2Fradio-gemtek-pci.c;h=74976cba869f521ae0d558b136f1979a991d46c0;hb=a9c87a10db08f53c5220f273d518390cbaeb55c8;hp=9f249e7e60c9b16d2a0d9b4081d18ea28a478d20;hpb=55b4d6a52195a8f277ffddf755ddaff359878f41;p=cascardo%2Flinux.git diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c index 9f249e7e60c9..74976cba869f 100644 --- a/drivers/media/radio/radio-gemtek-pci.c +++ b/drivers/media/radio/radio-gemtek-pci.c @@ -34,19 +34,42 @@ * * TODO: multiple device support and portability were not tested * + * Converted to V4L2 API by Mauro Carvalho Chehab + * *************************************************************************** */ -#include #include #include #include #include #include -#include +#include #include #include +#include /* for KERNEL_VERSION MACRO */ +#define RADIO_VERSION KERNEL_VERSION(0,0,2) + +static struct v4l2_queryctrl radio_qctrl[] = { + { + .id = V4L2_CID_AUDIO_MUTE, + .name = "Mute", + .minimum = 0, + .maximum = 1, + .default_value = 1, + .type = V4L2_CTRL_TYPE_BOOLEAN, + },{ + .id = V4L2_CID_AUDIO_VOLUME, + .name = "Volume", + .minimum = 0, + .maximum = 65535, + .step = 65535, + .default_value = 0xff, + .type = V4L2_CTRL_TYPE_INTEGER, + } +}; + #include #include @@ -66,14 +89,6 @@ #define GEMTEK_PCI_RANGE_HIGH (108*16000) #endif -#ifndef TRUE -#define TRUE (1) -#endif - -#ifndef FALSE -#define FALSE (0) -#endif - struct gemtek_pci_card { struct video_device *videodev; @@ -123,12 +138,12 @@ static void __gemtek_pci_cmd( u16 value, u32 port, u8 *last_byte, int keep ) static inline void gemtek_pci_nil( u32 port, u8 *last_byte ) { - __gemtek_pci_cmd( 0x00, port, last_byte, FALSE ); + __gemtek_pci_cmd( 0x00, port, last_byte, false ); } static inline void gemtek_pci_cmd( u16 cmd, u32 port, u8 *last_byte ) { - __gemtek_pci_cmd( cmd, port, last_byte, TRUE ); + __gemtek_pci_cmd( cmd, port, last_byte, true ); } static void gemtek_pci_setfrequency( struct gemtek_pci_card *card, unsigned long frequency ) @@ -161,14 +176,14 @@ static void gemtek_pci_setfrequency( struct gemtek_pci_card *card, unsigned long static inline void gemtek_pci_mute( struct gemtek_pci_card *card ) { outb( 0x1f, card->iobase ); - card->mute = TRUE; + card->mute = true; } static inline void gemtek_pci_unmute( struct gemtek_pci_card *card ) { if ( card->mute ) { gemtek_pci_setfrequency( card, card->current_frequency ); - card->mute = FALSE; + card->mute = false; } } @@ -184,91 +199,117 @@ static int gemtek_pci_do_ioctl(struct inode *inode, struct file *file, struct gemtek_pci_card *card = dev->priv; switch ( cmd ) { - case VIDIOCGCAP: + case VIDIOC_QUERYCAP: { - struct video_capability *c = arg; + struct v4l2_capability *v = arg; + memset(v,0,sizeof(*v)); + strlcpy(v->driver, "radio-gemtek-pci", sizeof (v->driver)); + strlcpy(v->card, "GemTek PCI Radio", sizeof (v->card)); + sprintf(v->bus_info,"ISA"); + v->version = RADIO_VERSION; + v->capabilities = V4L2_CAP_TUNER; - memset(c,0,sizeof(*c)); - c->type = VID_TYPE_TUNER; - c->channels = 1; - c->audios = 1; - strcpy( c->name, "Gemtek PCI Radio" ); return 0; } - - case VIDIOCGTUNER: + case VIDIOC_G_TUNER: { - struct video_tuner *t = arg; + struct v4l2_tuner *v = arg; - if ( t->tuner ) + if (v->index > 0) return -EINVAL; - t->rangelow = GEMTEK_PCI_RANGE_LOW; - t->rangehigh = GEMTEK_PCI_RANGE_HIGH; - t->flags = VIDEO_TUNER_LOW; - t->mode = VIDEO_MODE_AUTO; - t->signal = 0xFFFF * gemtek_pci_getsignal( card ); - strcpy( t->name, "FM" ); + memset(v,0,sizeof(*v)); + strcpy(v->name, "FM"); + v->type = V4L2_TUNER_RADIO; + + v->rangelow = GEMTEK_PCI_RANGE_LOW; + v->rangehigh = GEMTEK_PCI_RANGE_HIGH; + v->rxsubchans =V4L2_TUNER_SUB_MONO; + v->capability=V4L2_TUNER_CAP_LOW; + v->audmode = V4L2_TUNER_MODE_MONO; + v->signal=0xFFFF*gemtek_pci_getsignal( card ); + return 0; } - - case VIDIOCSTUNER: + case VIDIOC_S_TUNER: { - struct video_tuner *t = arg; - if ( t->tuner ) + struct v4l2_tuner *v = arg; + + if (v->index > 0) return -EINVAL; - return 0; - } - case VIDIOCGFREQ: - { - unsigned long *freq = arg; - *freq = card->current_frequency; return 0; } - case VIDIOCSFREQ: + case VIDIOC_S_FREQUENCY: { - unsigned long *freq = arg; + struct v4l2_frequency *f = arg; - if ( (*freq < GEMTEK_PCI_RANGE_LOW) || - (*freq > GEMTEK_PCI_RANGE_HIGH) ) + if ( (f->frequency < GEMTEK_PCI_RANGE_LOW) || + (f->frequency > GEMTEK_PCI_RANGE_HIGH) ) return -EINVAL; - gemtek_pci_setfrequency( card, *freq ); - card->current_frequency = *freq; - card->mute = FALSE; + gemtek_pci_setfrequency( card, f->frequency ); + card->current_frequency = f->frequency; + card->mute = false; return 0; } - - case VIDIOCGAUDIO: + case VIDIOC_QUERYCTRL: { - struct video_audio *a = arg; - - memset( a, 0, sizeof( *a ) ); - a->flags |= VIDEO_AUDIO_MUTABLE; - a->volume = 1; - a->step = 65535; - strcpy( a->name, "Radio" ); - return 0; + struct v4l2_queryctrl *qc = arg; + int i; + + for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { + if (qc->id && qc->id == radio_qctrl[i].id) { + memcpy(qc, &(radio_qctrl[i]), + sizeof(*qc)); + return (0); + } + } + return -EINVAL; } - - case VIDIOCSAUDIO: + case VIDIOC_G_CTRL: { - struct video_audio *a = arg; - - if ( a->audio ) - return -EINVAL; - - if ( a->flags & VIDEO_AUDIO_MUTE ) - gemtek_pci_mute( card ); - else - gemtek_pci_unmute( card ); - return 0; + struct v4l2_control *ctrl= arg; + + switch (ctrl->id) { + case V4L2_CID_AUDIO_MUTE: + ctrl->value=card->mute; + return (0); + case V4L2_CID_AUDIO_VOLUME: + if (card->mute) + ctrl->value=0; + else + ctrl->value=65535; + return (0); + } + return -EINVAL; + } + case VIDIOC_S_CTRL: + { + struct v4l2_control *ctrl= arg; + + switch (ctrl->id) { + case V4L2_CID_AUDIO_MUTE: + if (ctrl->value) { + gemtek_pci_mute(card); + } else { + gemtek_pci_unmute(card); + } + return (0); + case V4L2_CID_AUDIO_VOLUME: + if (ctrl->value) { + gemtek_pci_unmute(card); + } else { + gemtek_pci_mute(card); + } + return (0); + } + return -EINVAL; } - default: - return -ENOIOCTLCMD; + return v4l_compat_translate_ioctl(inode,file,cmd,arg, + gemtek_pci_do_ioctl); } } @@ -297,7 +338,7 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id ); static int mx = 1; -static struct file_operations gemtek_pci_fops = { +static const struct file_operations gemtek_pci_fops = { .owner = THIS_MODULE, .open = video_exclusive_open, .release = video_exclusive_release, @@ -310,7 +351,7 @@ static struct video_device vdev_template = { .owner = THIS_MODULE, .name = "Gemtek PCI Radio", .type = VID_TYPE_TUNER, - .hardware = VID_HARDWARE_GEMTEK, + .hardware = 0, .fops = &gemtek_pci_fops, }; @@ -400,7 +441,7 @@ static int __init gemtek_pci_init_module( void ) static void __exit gemtek_pci_cleanup_module( void ) { - return pci_unregister_driver( &gemtek_pci_driver ); + pci_unregister_driver(&gemtek_pci_driver); } MODULE_AUTHOR( "Vladimir Shebordaev " );