Commit 2fdf3d9c authored by Pantelis Koukousoulas's avatar Pantelis Koukousoulas Committed by Mauro Carvalho Chehab

V4L/DVB (5037): Pvrusb2: Implement multiple minor device number handling

This is the first patch in preparation of the V4L2/IVTV radio interface.
It does away with the assumption of only one minor per device. It also
adds a file to show the radio minor as well. This can be useful for a
program like pvr-radio.c (when it grows up), since this way it can search
for the minor of the /dev/radioX device it opened and use the video minor
of the same driver instance to get to the actual stream.

The implementation looks kinda ugly. Feel free to improve (that is the
reason behind separate patches anyway).
Signed-off-by: default avatarPantelis Koukousoulas <pakt223@freemail.gr>
Signed-off-by: default avatarMike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 6fcb5b3e
......@@ -281,9 +281,9 @@ struct pvr2_hdw {
int unit_number; /* ID for driver instance */
unsigned long serial_number; /* ID for hardware itself */
/* Minor number used by v4l logic (yes, this is a hack, as there should
be no v4l junk here). Probably a better way to do this. */
int v4l_minor_number;
/* Minor numbers used by v4l logic (yes, this is a hack, as there
should be no v4l junk here). Probably a better way to do this. */
int v4l_minor_number[3];
/* Location of eeprom or a negative number if none */
int eeprom_addr;
......
......@@ -1898,7 +1898,9 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
hdw->eeprom_addr = -1;
hdw->unit_number = -1;
hdw->v4l_minor_number = -1;
hdw->v4l_minor_number[0] = -1;
hdw->v4l_minor_number[1] = -1;
hdw->v4l_minor_number[2] = -1;
hdw->ctl_write_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
if (!hdw->ctl_write_buffer) goto fail;
hdw->ctl_read_buffer = kmalloc(PVR2_CTL_BUFFSIZE,GFP_KERNEL);
......@@ -2546,16 +2548,16 @@ int pvr2_hdw_cpufw_get(struct pvr2_hdw *hdw,unsigned int offs,
}
int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw)
int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *hdw,int index)
{
return hdw->v4l_minor_number;
return hdw->v4l_minor_number[index];
}
/* Store the v4l minor device number */
void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v)
/* Store a v4l minor device number */
void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int index,int v)
{
hdw->v4l_minor_number = v;
hdw->v4l_minor_number[index] = v;
}
......
......@@ -205,11 +205,11 @@ int pvr2_hdw_cpufw_get_enabled(struct pvr2_hdw *);
int pvr2_hdw_cpufw_get(struct pvr2_hdw *,unsigned int offs,
char *buf,unsigned int cnt);
/* Retrieve previously stored v4l minor device number */
int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *);
/* Retrieve a previously stored v4l minor device number */
int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *,int);
/* Store the v4l minor device number */
void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
/* Store a v4l minor device number */
void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int,int);
/* Direct read/write access to chip's registers:
chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
......
......@@ -40,8 +40,10 @@ struct pvr2_sysfs {
struct pvr2_sysfs_ctl_item *item_first;
struct pvr2_sysfs_ctl_item *item_last;
struct class_device_attribute attr_v4l_minor_number;
struct class_device_attribute attr_v4l_radio_minor_number;
struct class_device_attribute attr_unit_number;
int v4l_minor_number_created_ok;
int v4l_radio_minor_number_created_ok;
int unit_number_created_ok;
};
......@@ -709,6 +711,10 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
class_device_remove_file(sfp->class_dev,
&sfp->attr_v4l_minor_number);
}
if (sfp->v4l_radio_minor_number_created_ok) {
class_device_remove_file(sfp->class_dev,
&sfp->attr_v4l_radio_minor_number);
}
if (sfp->unit_number_created_ok) {
class_device_remove_file(sfp->class_dev,
&sfp->attr_unit_number);
......@@ -726,7 +732,18 @@ static ssize_t v4l_minor_number_show(struct class_device *class_dev,char *buf)
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
return scnprintf(buf,PAGE_SIZE,"%d\n",
pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw));
pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,0));
}
static ssize_t v4l_radio_minor_number_show(struct class_device *class_dev,
char *buf)
{
struct pvr2_sysfs *sfp;
sfp = (struct pvr2_sysfs *)class_dev->class_data;
if (!sfp) return -EINVAL;
return scnprintf(buf,PAGE_SIZE,"%d\n",
pvr2_hdw_v4l_get_minor_number(sfp->channel.hdw,2));
}
......@@ -793,6 +810,20 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
sfp->v4l_minor_number_created_ok = !0;
}
sfp->attr_v4l_radio_minor_number.attr.owner = THIS_MODULE;
sfp->attr_v4l_radio_minor_number.attr.name = "v4l_radio_minor_number";
sfp->attr_v4l_radio_minor_number.attr.mode = S_IRUGO;
sfp->attr_v4l_radio_minor_number.show = v4l_radio_minor_number_show;
sfp->attr_v4l_radio_minor_number.store = NULL;
ret = class_device_create_file(sfp->class_dev,
&sfp->attr_v4l_radio_minor_number);
if (ret < 0) {
printk(KERN_WARNING "%s: class_device_create_file error: %d\n",
__FUNCTION__, ret);
} else {
sfp->v4l_radio_minor_number_created_ok = !0;
}
sfp->attr_unit_number.attr.owner = THIS_MODULE;
sfp->attr_unit_number.attr.name = "unit_number";
sfp->attr_unit_number.attr.mode = S_IRUGO;
......
......@@ -722,7 +722,12 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
{
pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,-1);
pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
pvr2_config_mpeg-1,-1);
pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
pvr2_config_vbi-1,-1);
pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
pvr2_config_radio-1,-1);
pvr2_v4l2_dev_destroy(vp->vdev);
pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp);
......@@ -1062,7 +1067,7 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
}
pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
dip->devbase.minor);
cfg-1,dip->devbase.minor);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment