^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * ZyDAS ZD1301 driver (USB interface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2015 Antti Palosaari <crope@iki.fi>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "dvb_usb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "zd1301_demod.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "mt2060.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct zd1301_dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define BUF_LEN 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) u8 buf[BUF_LEN]; /* bulk USB control message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct zd1301_demod_platform_data demod_pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct mt2060_platform_data mt2060_pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct platform_device *platform_device_demod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct i2c_client *i2c_client_tuner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static int zd1301_ctrl_msg(struct dvb_usb_device *d, const u8 *wbuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) unsigned int wlen, u8 *rbuf, unsigned int rlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct zd1301_dev *dev = d_to_priv(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct usb_interface *intf = d->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int ret, actual_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) mutex_lock(&d->usb_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) memcpy(&dev->buf, wbuf, wlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) dev_dbg(&intf->dev, ">>> %*ph\n", wlen, dev->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev, 0x04), dev->buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) wlen, &actual_length, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) dev_err(&intf->dev, "1st usb_bulk_msg() failed %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) goto err_mutex_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (rlen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, 0x83),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) dev->buf, rlen, &actual_length, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) dev_err(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) "2nd usb_bulk_msg() failed %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) goto err_mutex_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) dev_dbg(&intf->dev, "<<< %*ph\n", actual_length, dev->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if (actual_length != rlen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * Chip replies often with 3 byte len stub. On that case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * we have to query new reply.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) dev_dbg(&intf->dev, "repeating reply message\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) ret = usb_bulk_msg(d->udev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) usb_rcvbulkpipe(d->udev, 0x83),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) dev->buf, rlen, &actual_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) dev_err(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) "3rd usb_bulk_msg() failed %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) goto err_mutex_unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) dev_dbg(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) "<<< %*ph\n", actual_length, dev->buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) memcpy(rbuf, dev->buf, rlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) err_mutex_unlock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) mutex_unlock(&d->usb_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static int zd1301_demod_wreg(void *reg_priv, u16 reg, u8 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct dvb_usb_device *d = reg_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct usb_interface *intf = d->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) u8 buf[7] = {0x07, 0x00, 0x03, 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) (reg >> 0) & 0xff, (reg >> 8) & 0xff, val};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) ret = zd1301_ctrl_msg(d, buf, 7, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) dev_dbg(&intf->dev, "failed=%d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static int zd1301_demod_rreg(void *reg_priv, u16 reg, u8 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct dvb_usb_device *d = reg_priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct usb_interface *intf = d->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) u8 buf[7] = {0x07, 0x00, 0x04, 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) (reg >> 0) & 0xff, (reg >> 8) & 0xff, 0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) ret = zd1301_ctrl_msg(d, buf, 7, buf, 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) *val = buf[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) dev_dbg(&intf->dev, "failed=%d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static int zd1301_frontend_attach(struct dvb_usb_adapter *adap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct dvb_usb_device *d = adap_to_d(adap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct zd1301_dev *dev = adap_to_priv(adap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct usb_interface *intf = d->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct platform_device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct i2c_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct i2c_board_info board_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct i2c_adapter *adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct dvb_frontend *frontend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) dev_dbg(&intf->dev, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* Add platform demod */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) dev->demod_pdata.reg_priv = d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) dev->demod_pdata.reg_read = zd1301_demod_rreg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) dev->demod_pdata.reg_write = zd1301_demod_wreg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) request_module("%s", "zd1301_demod");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) pdev = platform_device_register_data(&intf->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) "zd1301_demod",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) PLATFORM_DEVID_AUTO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) &dev->demod_pdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) sizeof(dev->demod_pdata));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (IS_ERR(pdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ret = PTR_ERR(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (!pdev->dev.driver) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!try_module_get(pdev->dev.driver->owner)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) goto err_platform_device_unregister;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) adapter = zd1301_demod_get_i2c_adapter(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) frontend = zd1301_demod_get_dvb_frontend(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (!adapter || !frontend) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) goto err_module_put_demod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /* Add I2C tuner */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) dev->mt2060_pdata.i2c_write_max = 9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) dev->mt2060_pdata.dvb_frontend = frontend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) memset(&board_info, 0, sizeof(board_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) strscpy(board_info.type, "mt2060", I2C_NAME_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) board_info.addr = 0x60;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) board_info.platform_data = &dev->mt2060_pdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) request_module("%s", "mt2060");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) client = i2c_new_client_device(adapter, &board_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (!i2c_client_has_driver(client)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) goto err_module_put_demod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) if (!try_module_get(client->dev.driver->owner)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) goto err_i2c_unregister_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) dev->platform_device_demod = pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) dev->i2c_client_tuner = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) adap->fe[0] = frontend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) err_i2c_unregister_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) i2c_unregister_device(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) err_module_put_demod:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) module_put(pdev->dev.driver->owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) err_platform_device_unregister:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) platform_device_unregister(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) dev_dbg(&intf->dev, "failed=%d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static int zd1301_frontend_detach(struct dvb_usb_adapter *adap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct dvb_usb_device *d = adap_to_d(adap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) struct zd1301_dev *dev = d_to_priv(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct usb_interface *intf = d->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) struct platform_device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct i2c_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) dev_dbg(&intf->dev, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) client = dev->i2c_client_tuner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) pdev = dev->platform_device_demod;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /* Remove I2C tuner */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (client) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) module_put(client->dev.driver->owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) i2c_unregister_device(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) /* Remove platform demod */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (pdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) module_put(pdev->dev.driver->owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) platform_device_unregister(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static int zd1301_streaming_ctrl(struct dvb_frontend *fe, int onoff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct dvb_usb_device *d = fe_to_d(fe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct usb_interface *intf = d->intf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) u8 buf[3] = {0x03, 0x00, onoff ? 0x07 : 0x08};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) dev_dbg(&intf->dev, "onoff=%d\n", onoff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) ret = zd1301_ctrl_msg(d, buf, 3, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) dev_dbg(&intf->dev, "failed=%d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static const struct dvb_usb_device_properties zd1301_props = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .driver_name = KBUILD_MODNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .adapter_nr = adapter_nr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .size_of_priv = sizeof(struct zd1301_dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .frontend_attach = zd1301_frontend_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) .frontend_detach = zd1301_frontend_detach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) .streaming_ctrl = zd1301_streaming_ctrl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) .num_adapters = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .adapter = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) .stream = DVB_USB_STREAM_BULK(0x81, 6, 21 * 188),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) static const struct usb_device_id zd1301_id_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {DVB_USB_DEVICE(USB_VID_ZYDAS, 0x13a1, &zd1301_props,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) "ZyDAS ZD1301 reference design", NULL)},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) MODULE_DEVICE_TABLE(usb, zd1301_id_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) /* Usb specific object needed to register this driver with the usb subsystem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static struct usb_driver zd1301_usb_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) .name = KBUILD_MODNAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) .id_table = zd1301_id_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) .probe = dvb_usbv2_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) .disconnect = dvb_usbv2_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) .suspend = dvb_usbv2_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) .resume = dvb_usbv2_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) .reset_resume = dvb_usbv2_reset_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) .no_dynamic_id = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) .soft_unbind = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) module_usb_driver(zd1301_usb_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) MODULE_DESCRIPTION("ZyDAS ZD1301 driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) MODULE_LICENSE("GPL");