mirror of
https://github.com/tsukumijima/px4_drv.git
synced 2025-07-23 04:03:01 +02:00
driver: ISDB2056 と ISDB2056N の同時利用に対応
今までは既存の ISDB2056 向けドライバを ISDB2056N 向けに改造していたため逆に既存の ISDB2056 では動作しなくなっていた この変更により、両方のデバイスを /dev/isdb2056video* として区別なく扱えるようになる
This commit is contained in:
@@ -514,11 +514,33 @@ static int isdb2056_chrdev_tune(struct ptx_chrdev *chrdev,
|
||||
break;
|
||||
}
|
||||
|
||||
ret = tc90522_write_reg(&chrdev2056->tc90522_s0, 0x07, 0x77);
|
||||
switch (isdb2056->isdb2056_model) {
|
||||
case ISDB2056_MODEL:
|
||||
ret = tc90522_write_reg(&chrdev2056->tc90522_s, 0x07, 0x77);
|
||||
break;
|
||||
case ISDB2056N_MODEL:
|
||||
ret = tc90522_write_reg(&chrdev2056->tc90522_s0, 0x07, 0x77);
|
||||
break;
|
||||
default:
|
||||
dev_err(isdb2056->dev, "isdb2056_chrdev_tune: undefined model (model: %d)\n", isdb2056->isdb2056_model);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
ret = tc90522_write_reg(&chrdev2056->tc90522_s0, 0x08, 0x37);
|
||||
switch (isdb2056->isdb2056_model) {
|
||||
case ISDB2056_MODEL:
|
||||
ret = tc90522_write_reg(&chrdev2056->tc90522_s, 0x08, 0x10);
|
||||
break;
|
||||
case ISDB2056N_MODEL:
|
||||
ret = tc90522_write_reg(&chrdev2056->tc90522_s0, 0x08, 0x37);
|
||||
break;
|
||||
default:
|
||||
dev_err(isdb2056->dev, "isdb2056_chrdev_tune: undefined model (model: %d)\n", isdb2056->isdb2056_model);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
@@ -885,6 +907,7 @@ static int isdb2056_device_load_config(struct isdb2056_device *isdb2056,
|
||||
chrdev2056->tc90522_t.i2c_addr = 0x10;
|
||||
chrdev2056->tc90522_t.is_secondary = false;
|
||||
|
||||
// This structure (tc90522_s0) is only required by ISDB2056N, but it is initialized in common just to be safe
|
||||
chrdev2056->tc90522_s0.dev = dev;
|
||||
chrdev2056->tc90522_s0.i2c = &it930x->i2c_master[2];
|
||||
chrdev2056->tc90522_s0.i2c_addr = 0x11;
|
||||
@@ -892,8 +915,21 @@ static int isdb2056_device_load_config(struct isdb2056_device *isdb2056,
|
||||
|
||||
chrdev2056->tc90522_s.dev = dev;
|
||||
chrdev2056->tc90522_s.i2c = &it930x->i2c_master[2];
|
||||
chrdev2056->tc90522_s.i2c_addr = 0x13;
|
||||
chrdev2056->tc90522_s.is_secondary = true;
|
||||
switch (isdb2056->isdb2056_model) {
|
||||
case ISDB2056_MODEL:
|
||||
// ISDB2056 TS demodulator: Toshiba TC90532XBG
|
||||
chrdev2056->tc90522_s.i2c_addr = 0x11;
|
||||
chrdev2056->tc90522_s.is_secondary = false;
|
||||
break;
|
||||
case ISDB2056N_MODEL:
|
||||
// ISDB2056N TS demodulator: Toshiba TC90522XBG
|
||||
chrdev2056->tc90522_s.i2c_addr = 0x13;
|
||||
chrdev2056->tc90522_s.is_secondary = true;
|
||||
break;
|
||||
default:
|
||||
dev_err(dev, "isdb2056_device_load_config: undefined model (model: %d)\n", isdb2056->isdb2056_model);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
chrdev2056->r850.dev = dev;
|
||||
chrdev2056->r850.i2c = &chrdev2056->tc90522_t.i2c_master;
|
||||
@@ -925,6 +961,7 @@ static int isdb2056_device_load_config(struct isdb2056_device *isdb2056,
|
||||
}
|
||||
|
||||
int isdb2056_device_init(struct isdb2056_device *isdb2056, struct device *dev,
|
||||
enum isdb2056_model isdb2056_model,
|
||||
struct ptx_chrdev_context *chrdev_ctx,
|
||||
struct completion *quit_completion)
|
||||
{
|
||||
@@ -945,6 +982,7 @@ int isdb2056_device_init(struct isdb2056_device *isdb2056, struct device *dev,
|
||||
|
||||
kref_init(&isdb2056->kref);
|
||||
isdb2056->dev = dev;
|
||||
isdb2056->isdb2056_model = isdb2056_model;
|
||||
isdb2056->quit_completion = quit_completion;
|
||||
|
||||
stream_ctx = kzalloc(sizeof(*stream_ctx), GFP_KERNEL);
|
||||
|
@@ -22,6 +22,11 @@
|
||||
|
||||
#define ISDB2056_CHRDEV_NUM 1
|
||||
|
||||
enum isdb2056_model {
|
||||
ISDB2056_MODEL = 0,
|
||||
ISDB2056N_MODEL,
|
||||
};
|
||||
|
||||
struct isdb2056_chrdev {
|
||||
struct ptx_chrdev *chrdev;
|
||||
struct tc90522_demod tc90522_t;
|
||||
@@ -35,6 +40,7 @@ struct isdb2056_device {
|
||||
struct kref kref;
|
||||
atomic_t available;
|
||||
struct device *dev;
|
||||
enum isdb2056_model isdb2056_model;
|
||||
struct completion *quit_completion;
|
||||
struct ptx_chrdev_group *chrdev_group;
|
||||
struct isdb2056_chrdev chrdev2056;
|
||||
@@ -43,6 +49,7 @@ struct isdb2056_device {
|
||||
};
|
||||
|
||||
int isdb2056_device_init(struct isdb2056_device *isdb2056, struct device *dev,
|
||||
enum isdb2056_model isdb2056_model,
|
||||
struct ptx_chrdev_context *chrdev_ctx,
|
||||
struct completion *quit_completion);
|
||||
void isdb2056_device_term(struct isdb2056_device *isdb2056);
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "print_format.h"
|
||||
#include "ptx_chrdev.h"
|
||||
#include "isdb2056_device.h"
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/slab.h>
|
||||
@@ -894,6 +895,25 @@ int ptx_chrdev_context_add_group(struct ptx_chrdev_context *chrdev_ctx,
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
dev_info(dev, "/dev/%s%u\n", chrdev_ctx->devname, base + i);
|
||||
if (strncmp(chrdev_ctx->devname, "isdb2056", 8) == 0) {
|
||||
// If the device is ISDB2056 or ISDB2056N, print the model name
|
||||
struct ptx_chrdev *chrdev = &group->chrdev[i];
|
||||
struct isdb2056_chrdev *chrdev2056 = chrdev->priv;
|
||||
struct isdb2056_device *isdb2056 = container_of(chrdev2056, struct isdb2056_device, chrdev2056);
|
||||
const char *model_name;
|
||||
switch (isdb2056->isdb2056_model) {
|
||||
case ISDB2056_MODEL:
|
||||
model_name = "ISDB2056";
|
||||
break;
|
||||
case ISDB2056N_MODEL:
|
||||
model_name = "ISDB2056N";
|
||||
break;
|
||||
default:
|
||||
model_name = "Unknown";
|
||||
break;
|
||||
}
|
||||
dev_info(dev, "/dev/%s%u: Digibest %s\n", chrdev_ctx->devname, base + i, model_name);
|
||||
}
|
||||
device_create(chrdev_ctx->class, dev,
|
||||
MKDEV(MAJOR(chrdev_ctx->dev_base),
|
||||
group->minor_base + i),
|
||||
|
@@ -54,12 +54,12 @@
|
||||
#ifndef PXM1UR_USB_MAX_DEVICE
|
||||
#define PXM1UR_USB_MAX_DEVICE 64
|
||||
#endif
|
||||
#define PXM1UR_USB_MAX_CHRDEV (PXM1UR_USB_MAX_DEVICE * ISDB2056_CHRDEV_NUM)
|
||||
#define PXM1UR_USB_MAX_CHRDEV (PXM1UR_USB_MAX_DEVICE * M1UR_CHRDEV_NUM)
|
||||
|
||||
#ifndef PXS1UR_USB_MAX_DEVICE
|
||||
#define PXS1UR_USB_MAX_DEVICE 64
|
||||
#endif
|
||||
#define PXS1UR_USB_MAX_CHRDEV (PXS1UR_USB_MAX_DEVICE * ISDB2056_CHRDEV_NUM)
|
||||
#define PXS1UR_USB_MAX_CHRDEV (PXS1UR_USB_MAX_DEVICE * S1UR_CHRDEV_NUM)
|
||||
|
||||
|
||||
struct px4_usb_context {
|
||||
@@ -69,8 +69,8 @@ struct px4_usb_context {
|
||||
struct px4_device px4;
|
||||
struct pxmlt_device pxmlt;
|
||||
struct isdb2056_device isdb2056;
|
||||
struct s1ur_device s1ur;
|
||||
struct m1ur_device m1ur;
|
||||
struct s1ur_device s1ur;
|
||||
} ctx;
|
||||
};
|
||||
|
||||
@@ -187,7 +187,7 @@ static int px4_usb_probe(struct usb_interface *intf,
|
||||
break;
|
||||
|
||||
ctx->type = ISDB2056_USB_DEVICE;
|
||||
ret = isdb2056_device_init(&ctx->ctx.isdb2056, dev,
|
||||
ret = isdb2056_device_init(&ctx->ctx.isdb2056, dev, ISDB2056_MODEL,
|
||||
px4_usb_chrdev_ctx[ISDB2056_USB_DEVICE],
|
||||
&ctx->quit_completion);
|
||||
break;
|
||||
@@ -199,7 +199,7 @@ static int px4_usb_probe(struct usb_interface *intf,
|
||||
break;
|
||||
|
||||
ctx->type = ISDB2056_USB_DEVICE;
|
||||
ret = isdb2056_device_init(&ctx->ctx.isdb2056, dev,
|
||||
ret = isdb2056_device_init(&ctx->ctx.isdb2056, dev, ISDB2056N_MODEL,
|
||||
px4_usb_chrdev_ctx[ISDB2056_USB_DEVICE],
|
||||
&ctx->quit_completion);
|
||||
break;
|
||||
@@ -218,7 +218,7 @@ static int px4_usb_probe(struct usb_interface *intf,
|
||||
|
||||
case USB_PID_PX_M1UR:
|
||||
ret = px4_usb_init_bridge(dev, usb_dev,
|
||||
&ctx->ctx.isdb2056.it930x);
|
||||
&ctx->ctx.m1ur.it930x);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
@@ -230,7 +230,7 @@ static int px4_usb_probe(struct usb_interface *intf,
|
||||
|
||||
case USB_PID_PX_S1UR:
|
||||
ret = px4_usb_init_bridge(dev, usb_dev,
|
||||
&ctx->ctx.s1ur.it930x);
|
||||
&ctx->ctx.s1ur.it930x);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user