/* * initialize all the tea575x chips */ void snd_tea575x_init(struct snd_tea575x *tea) { unsigned int val; val = tea->ops->read(tea); if (val == 0x1ffffff || val == 0) { snd_printk(KERN_ERR "Cannot find TEA575x chip\n"); return; } memset(&tea->vd, 0, sizeof(tea->vd)); tea->vd.owner = tea->card->module; strcpy(tea->vd.name, tea->tea5759 ? "TEA5759 radio" : "TEA5757 radio"); tea->vd.type = VID_TYPE_TUNER; tea->vd.release = snd_tea575x_release; video_set_drvdata(&tea->vd, tea); tea->vd.fops = &tea->fops; tea->fops.owner = tea->card->module; tea->fops.open = video_exclusive_open; tea->fops.release = video_exclusive_release; tea->fops.ioctl = snd_tea575x_ioctl; if (video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->dev_nr - 1) < 0) { snd_printk(KERN_ERR "unable to register tea575x tuner\n"); return; } tea->vd_registered = 1; tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40; tea->freq = 90500 * 16; /* 90.5Mhz default */ snd_tea575x_set_freq(tea); }
static int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { struct snd_tea575x *tea = video_drvdata(file); if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) return -EINVAL; tea->freq = f->frequency; snd_tea575x_set_freq(tea); return 0; }
/* * initialize all the tea575x chips */ void snd_tea575x_init(struct snd_tea575x *tea) { int retval; unsigned int val; struct video_device *tea575x_radio_inst; val = tea->ops->read(tea); if (val == 0x1ffffff || val == 0) { snd_printk(KERN_ERR "tea575x-tuner: Cannot find TEA575x chip\n"); return; } tea->in_use = 0; tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40; tea->freq = 90500 * 16; /* 90.5Mhz default */ tea575x_radio_inst = video_device_alloc(); if (tea575x_radio_inst == NULL) { printk(KERN_ERR "tea575x-tuner: not enough memory\n"); return; } memcpy(tea575x_radio_inst, &tea575x_radio, sizeof(tea575x_radio)); strcpy(tea575x_radio.name, tea->tea5759 ? "TEA5759 radio" : "TEA5757 radio"); video_set_drvdata(tea575x_radio_inst, tea); retval = video_register_device(tea575x_radio_inst, VFL_TYPE_RADIO, radio_nr); if (retval) { printk(KERN_ERR "tea575x-tuner: can't register video device!\n"); kfree(tea575x_radio_inst); return; } snd_tea575x_set_freq(tea); #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17) /* mute on init */ if (tea->ops->mute) { tea->ops->mute(tea, 1); tea->mute = 1; } #endif tea->vd = tea575x_radio_inst; }
static int snd_tea575x_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data) { struct video_device *dev = video_devdata(file); struct snd_tea575x *tea = video_get_drvdata(dev); void __user *arg = (void __user *)data; switch(cmd) { case VIDIOCGCAP: { struct video_capability v; v.type = VID_TYPE_TUNER; v.channels = 1; v.audios = 1; /* No we don't do pictures */ v.maxwidth = 0; v.maxheight = 0; v.minwidth = 0; v.minheight = 0; strcpy(v.name, tea->tea5759 ? "TEA5759" : "TEA5757"); if (copy_to_user(arg,&v,sizeof(v))) return -EFAULT; return 0; } case VIDIOCGTUNER: { struct video_tuner v; if (copy_from_user(&v, arg,sizeof(v))!=0) return -EFAULT; if (v.tuner) /* Only 1 tuner */ return -EINVAL; v.rangelow = (87*16000); v.rangehigh = (108*16000); v.flags = VIDEO_TUNER_LOW; v.mode = VIDEO_MODE_AUTO; strcpy(v.name, "FM"); v.signal = 0xFFFF; if (copy_to_user(arg, &v, sizeof(v))) return -EFAULT; return 0; } case VIDIOCSTUNER: { struct video_tuner v; if(copy_from_user(&v, arg, sizeof(v))) return -EFAULT; if(v.tuner!=0) return -EINVAL; /* Only 1 tuner so no setting needed ! */ return 0; } case VIDIOCGFREQ: if(copy_to_user(arg, &tea->freq, sizeof(tea->freq))) return -EFAULT; return 0; case VIDIOCSFREQ: if(copy_from_user(&tea->freq, arg, sizeof(tea->freq))) return -EFAULT; snd_tea575x_set_freq(tea); return 0; case VIDIOCGAUDIO: { struct video_audio v; memset(&v, 0, sizeof(v)); strcpy(v.name, "Radio"); if(copy_to_user(arg,&v, sizeof(v))) return -EFAULT; return 0; } case VIDIOCSAUDIO: { struct video_audio v; if(copy_from_user(&v, arg, sizeof(v))) return -EFAULT; if(v.audio) return -EINVAL; return 0; } default: return -ENOIOCTLCMD; } }