FreeBSD kernel usb device Code
ugold.c File Reference
#include <sys/cdefs.h>
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/unistd.h>
#include <sys/callout.h>
#include <sys/malloc.h>
#include <sys/priv.h>
#include <sys/conf.h>
#include <dev/hid/hid.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbhid.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usbdi_util.h>
#include "usbdevs.h"
#include <dev/usb/usb_debug.h>
Include dependency graph for ugold.c:

Go to the source code of this file.

Data Structures

struct  ugold_readout_msg
 
struct  ugold_softc
 

Macros

#define USB_DEBUG_VAR   usb_debug
 
#define UGOLD_INNER   0
 
#define UGOLD_OUTER   1
 
#define UGOLD_MAX_SENSORS   2
 
#define UGOLD_CMD_DATA   0x80
 
#define UGOLD_CMD_INIT   0x82
 

Enumerations

enum  { UGOLD_INTR_DT , UGOLD_N_TRANSFER }
 

Functions

 __FBSDID ("$FreeBSD$")
 
 DRIVER_MODULE (ugold, uhub, ugold_driver, ugold_devclass, NULL, NULL)
 
 MODULE_DEPEND (ugold, usb, 1, 1, 1)
 
 MODULE_DEPEND (ugold, hid, 1, 1, 1)
 
 MODULE_VERSION (ugold, 1)
 
 USB_PNP_HOST_INFO (ugold_devs)
 
static void ugold_timeout (void *arg)
 
static int ugold_probe (device_t dev)
 
static int ugold_attach (device_t dev)
 
static int ugold_detach (device_t dev)
 
static int ugold_ds75_temp (uint8_t msb, uint8_t lsb)
 
static void ugold_intr_callback (struct usb_xfer *xfer, usb_error_t error)
 
static int ugold_issue_cmd (struct ugold_softc *sc, uint8_t *cmd, int len)
 
static void ugold_readout_msg (struct usb_proc_msg *pm)
 

Variables

static uint8_t cmd_data [8] = {0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00}
 
static uint8_t cmd_init [8] = {0x01, 0x82, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00}
 
static device_probe_t ugold_probe
 
static device_attach_t ugold_attach
 
static device_detach_t ugold_detach
 
static usb_proc_callback_t ugold_readout_msg
 
static usb_callback_t ugold_intr_callback
 
static devclass_t ugold_devclass
 
static device_method_t ugold_methods []
 
static driver_t ugold_driver
 
static const STRUCT_USB_HOST_ID ugold_devs []
 
static const struct usb_config ugold_config [UGOLD_N_TRANSFER]
 

Macro Definition Documentation

◆ UGOLD_CMD_DATA

#define UGOLD_CMD_DATA   0x80

Definition at line 61 of file ugold.c.

◆ UGOLD_CMD_INIT

#define UGOLD_CMD_INIT   0x82

Definition at line 62 of file ugold.c.

◆ UGOLD_INNER

#define UGOLD_INNER   0

Definition at line 57 of file ugold.c.

◆ UGOLD_MAX_SENSORS

#define UGOLD_MAX_SENSORS   2

Definition at line 59 of file ugold.c.

◆ UGOLD_OUTER

#define UGOLD_OUTER   1

Definition at line 58 of file ugold.c.

◆ USB_DEBUG_VAR

#define USB_DEBUG_VAR   usb_debug

Definition at line 54 of file ugold.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UGOLD_INTR_DT 
UGOLD_N_TRANSFER 

Definition at line 64 of file ugold.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( ugold  ,
uhub  ,
ugold_driver  ,
ugold_devclass  ,
NULL  ,
NULL   
)

◆ MODULE_DEPEND() [1/2]

MODULE_DEPEND ( ugold  ,
hid  ,
,
,
 
)

◆ MODULE_DEPEND() [2/2]

MODULE_DEPEND ( ugold  ,
usb  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( ugold  ,
 
)

◆ ugold_attach()

◆ ugold_detach()

static int ugold_detach ( device_t  dev)
static

◆ ugold_ds75_temp()

static int ugold_ds75_temp ( uint8_t  msb,
uint8_t  lsb 
)
static

Definition at line 313 of file ugold.c.

Referenced by ugold_intr_callback().

Here is the caller graph for this function:

◆ ugold_intr_callback()

◆ ugold_issue_cmd()

static int ugold_issue_cmd ( struct ugold_softc sc,
uint8_t *  cmd,
int  len 
)
static

Definition at line 386 of file ugold.c.

References len, ugold_softc::sc_iface_index, ugold_softc::sc_mtx, ugold_softc::sc_report_id, ugold_softc::sc_udev, UHID_OUTPUT_REPORT, and usbd_req_set_report().

Referenced by ugold_readout_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ugold_probe()

static int ugold_probe ( device_t  dev)
static

◆ ugold_readout_msg()

static void ugold_readout_msg ( struct usb_proc_msg pm)
static

◆ ugold_timeout()

static void ugold_timeout ( void *  arg)
static

Definition at line 164 of file ugold.c.

References ugold_softc::sc_callout, ugold_softc::sc_readout_msg, ugold_softc::sc_udev, ugold_timeout(), usb_proc_explore_lock(), usb_proc_explore_msignal(), and usb_proc_explore_unlock().

Referenced by ugold_attach(), and ugold_timeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ USB_PNP_HOST_INFO()

USB_PNP_HOST_INFO ( ugold_devs  )

Variable Documentation

◆ cmd_data

uint8_t cmd_data[8] = {0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00}
static

Definition at line 85 of file ugold.c.

Referenced by ugold_readout_msg().

◆ cmd_init

uint8_t cmd_init[8] = {0x01, 0x82, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00}
static

Definition at line 86 of file ugold.c.

Referenced by ugold_readout_msg().

◆ ugold_attach

device_attach_t ugold_attach
static

Definition at line 118 of file ugold.c.

◆ ugold_config

const struct usb_config ugold_config[UGOLD_N_TRANSFER]
static
Initial value:
= {
.type = UE_INTERRUPT,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
.flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
.bufsize = 0,
.callback = &ugold_intr_callback,
.if_index = 1,
},
}
static usb_callback_t ugold_intr_callback
Definition: ugold.c:123
@ UGOLD_INTR_DT
Definition: ugold.c:65
#define UE_INTERRUPT
Definition: usb.h:544
#define UE_ADDR_ANY
Definition: usb.h:537
#define UE_DIR_IN
Definition: usb.h:531

Definition at line 151 of file ugold.c.

Referenced by ugold_attach().

◆ ugold_detach

device_detach_t ugold_detach
static

Definition at line 119 of file ugold.c.

Referenced by ugold_attach().

◆ ugold_devclass

devclass_t ugold_devclass
static

Definition at line 125 of file ugold.c.

◆ ugold_devs

const STRUCT_USB_HOST_ID ugold_devs[]
static
Initial value:
= {
{USB_VPI(USB_VENDOR_CHICONY2, USB_PRODUCT_CHICONY2_TEMPER, 0)},
}
#define USB_VPI(vend, prod, info)
Definition: usbdi.h:367

Definition at line 141 of file ugold.c.

Referenced by ugold_probe().

◆ ugold_driver

driver_t ugold_driver
static
Initial value:
= {
.name = "ugold",
.methods = ugold_methods,
.size = sizeof(struct ugold_softc),
}
static device_method_t ugold_methods[]
Definition: ugold.c:127

Definition at line 135 of file ugold.c.

◆ ugold_intr_callback

usb_callback_t ugold_intr_callback
static

Definition at line 123 of file ugold.c.

◆ ugold_methods

device_method_t ugold_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, ugold_probe),
DEVMETHOD(device_attach, ugold_attach),
DEVMETHOD(device_detach, ugold_detach),
DEVMETHOD_END
}
static device_detach_t ugold_detach
Definition: ugold.c:119
static device_attach_t ugold_attach
Definition: ugold.c:118
static device_probe_t ugold_probe
Definition: ugold.c:117

Definition at line 127 of file ugold.c.

◆ ugold_probe

device_probe_t ugold_probe
static

Definition at line 117 of file ugold.c.

◆ ugold_readout_msg

Definition at line 121 of file ugold.c.

Referenced by ugold_attach().