1 1.5 riastrad /* $NetBSD: emdtvvar.h,v 1.5 2022/06/26 22:49:09 riastradh Exp $ */ 2 1.1 jmcneill 3 1.1 jmcneill /*- 4 1.1 jmcneill * Copyright (c) 2008 Jared D. McNeill <jmcneill (at) invisible.ca> 5 1.1 jmcneill * All rights reserved. 6 1.1 jmcneill * 7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without 8 1.1 jmcneill * modification, are permitted provided that the following conditions 9 1.1 jmcneill * are met: 10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright 11 1.1 jmcneill * notice, this list of conditions and the following disclaimer. 12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the 14 1.1 jmcneill * documentation and/or other materials provided with the distribution. 15 1.1 jmcneill * 16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 1.1 jmcneill * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 1.1 jmcneill * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 1.1 jmcneill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 1.1 jmcneill * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 1.1 jmcneill * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 1.1 jmcneill * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 1.1 jmcneill * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 1.1 jmcneill * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 1.1 jmcneill * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 1.1 jmcneill * POSSIBILITY OF SUCH DAMAGE. 27 1.1 jmcneill */ 28 1.1 jmcneill 29 1.1 jmcneill #ifndef _DEV_USB_EMDTVVAR_H 30 1.1 jmcneill #define _DEV_USB_EMDTVVAR_H 31 1.1 jmcneill 32 1.1 jmcneill #include <sys/mutex.h> 33 1.1 jmcneill #include <sys/condvar.h> 34 1.1 jmcneill #include <sys/workqueue.h> 35 1.1 jmcneill 36 1.1 jmcneill #include <dev/usb/usb.h> 37 1.1 jmcneill #include <dev/usb/usbdi.h> 38 1.1 jmcneill 39 1.1 jmcneill #include <dev/usb/emdtv_board.h> 40 1.1 jmcneill 41 1.1 jmcneill #include <dev/i2c/i2cvar.h> 42 1.1 jmcneill #include <dev/dtv/dtvif.h> 43 1.1 jmcneill 44 1.1 jmcneill #include <dev/i2c/lg3303var.h> 45 1.1 jmcneill #include <dev/i2c/xc3028var.h> 46 1.1 jmcneill 47 1.1 jmcneill #define EMDTV_EEPROM_LEN 256 48 1.1 jmcneill 49 1.1 jmcneill #define EMDTV_NXFERS 6 50 1.1 jmcneill #define EMDTV_NFRAMES 64 51 1.1 jmcneill 52 1.1 jmcneill #define EMDTV_CIR_BUFLEN 32 53 1.1 jmcneill 54 1.1 jmcneill struct emdtv_softc; 55 1.1 jmcneill 56 1.1 jmcneill struct emdtv_isoc_xfer { 57 1.1 jmcneill struct emdtv_softc *ix_sc; 58 1.4 skrll struct usbd_xfer *ix_xfer; 59 1.1 jmcneill uint8_t *ix_buf; 60 1.1 jmcneill uint16_t ix_frlengths[EMDTV_NFRAMES]; 61 1.1 jmcneill struct emdtv_isoc_xfer *ix_altix; 62 1.1 jmcneill }; 63 1.1 jmcneill 64 1.1 jmcneill struct emdtv_softc { 65 1.1 jmcneill device_t sc_dev; 66 1.4 skrll struct usbd_device *sc_udev; 67 1.1 jmcneill 68 1.1 jmcneill device_t sc_cirdev; 69 1.1 jmcneill device_t sc_dtvdev; 70 1.1 jmcneill 71 1.1 jmcneill uint16_t sc_vendor, sc_product; 72 1.1 jmcneill 73 1.5 riastrad bool sc_subdevs_attached; 74 1.5 riastrad 75 1.1 jmcneill const struct emdtv_board *sc_board; 76 1.1 jmcneill 77 1.1 jmcneill struct lg3303 *sc_lg3303; 78 1.1 jmcneill struct xc3028 *sc_xc3028; 79 1.1 jmcneill 80 1.1 jmcneill struct i2c_controller sc_i2c; 81 1.1 jmcneill kmutex_t sc_i2c_lock; 82 1.1 jmcneill 83 1.1 jmcneill uint8_t sc_eeprom[EMDTV_EEPROM_LEN]; 84 1.1 jmcneill 85 1.4 skrll struct usbd_interface *sc_iface; 86 1.1 jmcneill 87 1.4 skrll struct usbd_pipe *sc_isoc_pipe; 88 1.1 jmcneill int sc_isoc_buflen; 89 1.1 jmcneill int sc_isoc_maxpacketsize; 90 1.1 jmcneill struct emdtv_isoc_xfer sc_ix[EMDTV_NXFERS]; 91 1.1 jmcneill 92 1.4 skrll struct usbd_pipe *sc_intr_pipe; 93 1.1 jmcneill uint8_t sc_intr_buf; 94 1.1 jmcneill struct workqueue *sc_ir_wq; 95 1.1 jmcneill struct work sc_ir_work; 96 1.1 jmcneill uint8_t sc_ir_keyid; 97 1.1 jmcneill 98 1.1 jmcneill kmutex_t sc_ir_mutex; 99 1.1 jmcneill uint8_t sc_ir_queue[EMDTV_CIR_BUFLEN][3]; 100 1.1 jmcneill int sc_ir_cnt; 101 1.1 jmcneill int sc_ir_ptr; 102 1.1 jmcneill bool sc_ir_open; 103 1.1 jmcneill 104 1.1 jmcneill uint32_t sc_frequency; 105 1.1 jmcneill 106 1.1 jmcneill bool sc_streaming; 107 1.3 jmcneill void (*sc_dtvsubmitcb)(void *, 108 1.3 jmcneill const struct dtv_payload *); 109 1.3 jmcneill void *sc_dtvsubmitarg; 110 1.1 jmcneill 111 1.1 jmcneill bool sc_dying; 112 1.1 jmcneill }; 113 1.1 jmcneill 114 1.1 jmcneill void emdtv_dtv_attach(struct emdtv_softc *); 115 1.1 jmcneill void emdtv_dtv_detach(struct emdtv_softc *, int); 116 1.3 jmcneill void emdtv_dtv_rescan(struct emdtv_softc *, const char *, const int *); 117 1.1 jmcneill void emdtv_ir_attach(struct emdtv_softc *); 118 1.1 jmcneill void emdtv_ir_detach(struct emdtv_softc *, int); 119 1.1 jmcneill int emdtv_i2c_attach(struct emdtv_softc *); 120 1.1 jmcneill int emdtv_i2c_detach(struct emdtv_softc *, int); 121 1.1 jmcneill 122 1.1 jmcneill uint8_t emdtv_read_1(struct emdtv_softc *, uint8_t, uint16_t); 123 1.1 jmcneill void emdtv_read_multi_1(struct emdtv_softc *, uint8_t, uint16_t, 124 1.1 jmcneill uint8_t *, uint16_t); 125 1.1 jmcneill void emdtv_write_1(struct emdtv_softc *, uint8_t, uint16_t, uint8_t); 126 1.1 jmcneill void emdtv_write_multi_1(struct emdtv_softc *, uint8_t, uint16_t, 127 1.1 jmcneill const uint8_t *, uint16_t); 128 1.1 jmcneill 129 1.1 jmcneill bool emdtv_gpio_ctl(struct emdtv_softc *, emdtv_gpio_reg_t, bool); 130 1.1 jmcneill 131 1.1 jmcneill #endif /* !_DEV_USB_EMDTVVAR_H */ 132