PERFORCE change 122894 for review
Rui Paulo
rpaulo at FreeBSD.org
Thu Jul 5 00:47:41 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122894
Change 122894 by rpaulo at rpaulo_epsilon on 2007/07/05 00:47:29
Rename the softc sms variables to include a proper prefix.
Pointed out by: attilio
Affected files ...
.. //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#17 edit
.. //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmcvar.h#8 edit
.. //depot/projects/soc2007/rpaulo-macbook/dev/usb/atp.c#4 edit
Differences ...
==== //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#17 (text+ko) ====
@@ -23,7 +23,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#16 $
+ * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmc.c#17 $
*
*/
@@ -374,11 +374,11 @@
* interrupt. An interrupt from the SMS means that the
* disk heads should be turned off as quickly as possible.
*/
- TASK_INIT(&sc->sms_task, 0, asmc_sms_task, sc);
- sc->sms_tq = taskqueue_create_fast("asmc_taskq", M_WAITOK,
- taskqueue_thread_enqueue,
- &sc->sms_tq);
- taskqueue_start_threads(&sc->sms_tq, 1, PI_REALTIME, "%s sms taskq",
+ TASK_INIT(&sc->sc_sms_task, 0, asmc_sms_task, sc);
+ sc->sc_sms_tq = taskqueue_create_fast("asmc_taskq", M_WAITOK,
+ taskqueue_thread_enqueue,
+ &sc->sc_sms_tq);
+ taskqueue_start_threads(&sc->sc_sms_tq, 1, PI_REALTIME, "%s sms taskq",
device_get_nameunit(dev));
@@ -390,7 +390,7 @@
ASMC_IRQ, ASMC_IRQ, 1, RF_ACTIVE);
if (sc->sc_res == NULL) {
device_printf(dev, "unable to allocate IRQ resource\n");
- taskqueue_free(sc->sms_tq);
+ taskqueue_free(sc->sc_sms_tq);
goto out;
}
@@ -424,9 +424,9 @@
sysctl_ctx_free(&sc->sc_sysctl_ctx);
- if (sc->sms_tq) {
- taskqueue_drain(sc->sms_tq, &sc->sms_task);
- taskqueue_free(sc->sms_tq);
+ if (sc->sc_sms_tq) {
+ taskqueue_drain(sc->sc_sms_tq, &sc->sc_sms_task);
+ taskqueue_free(sc->sc_sms_tq);
}
if (sc->sc_cookie)
@@ -796,9 +796,9 @@
type = inb(ASMC_INTPORT);
mtx_unlock_spin(&sc->sc_mtx);
- sc->sms_intrtype = type;
+ sc->sc_sms_intrtype = type;
asmc_sms_printintr(dev, type);
- taskqueue_enqueue(sc->sms_tq, &sc->sms_task);
+ taskqueue_enqueue(sc->sc_sms_tq, &sc->sc_sms_task);
return (FILTER_HANDLED);
}
@@ -814,9 +814,9 @@
type = inb(ASMC_INTPORT);
mtx_unlock_spin(&sc->sc_mtx);
- sc->sms_intrtype = type;
+ sc->sc_sms_intrtype = type;
asmc_sms_printintr(dev, type);
- taskqueue_enqueue_fast(sc->sms_tq, &sc->sms_task);
+ taskqueue_enqueue_fast(sc->sc_sms_tq, &sc->sc_sms_task);
}
@@ -846,7 +846,7 @@
char notify[16];
int type;
- switch (sc->sms_intrtype) {
+ switch (sc->sc_sms_intrtype) {
case ASMC_SMS_INTFF:
type = 0;
break;
==== //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmcvar.h#8 (text+ko) ====
@@ -23,7 +23,7 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmcvar.h#7 $
+ * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/asmc/asmcvar.h#8 $
*
*/
@@ -45,9 +45,9 @@
int sc_rid;
struct resource *sc_res;
void *sc_cookie;
- int sms_intrtype;
- struct taskqueue *sms_tq;
- struct task sms_task;
+ int sc_sms_intrtype;
+ struct taskqueue *sc_sms_tq;
+ struct task sc_sms_task;
};
struct asmc_model {
==== //depot/projects/soc2007/rpaulo-macbook/dev/usb/atp.c#4 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/usb/atp.c#3 $
+ * $P4: //depot/projects/soc2007/rpaulo-macbook/dev/usb/atp.c#4 $
*/
#include <sys/cdefs.h>
@@ -71,6 +71,10 @@
static int atp_attach(device_t);
static int atp_detach(device_t);
+static int atp_enable(device_t);
+static int atp_disable(device_t);
+static void atp_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
+
/*
* char device interface.
*/
@@ -93,7 +97,19 @@
struct atp_softc {
device_t sc_dev;
+ int sc_enabled;
+
+ u_char *sc_ibuf;
+ int sc_isize;
+ usbd_interface_handle sc_iface; /* interface */
+ usbd_pipe_handle sc_intrpipe; /* interrupt pipe */
+ int sc_ep_addr;
+
+ mousehw_t hw;
+ mousemode_t mode;
+ mousestatus_t status;
+ struct cdev *dev; /* specfs */
};
static device_method_t atp_methods[] = {
@@ -169,17 +185,116 @@
static int
atp_attach(device_t self)
{
+ struct atp_softc *sc = device_get_softc(self);
+ struct usb_attach_arg *uaa = device_get_ivars(self);
+ usbd_interface_handle iface = uaa->iface;
+ usb_interface_descriptor_t *id;
+ usb_endpoint_descriptor_t *ed;
+ usbd_status err;
+ int size;
+ void *desc;
+ uint32_t flags;
+
+
+ struct hid_location a;
+
+ sc->sc_dev = self;
+
+ id = usbd_get_interface_descriptor(iface);
+ ed = usbd_interface2endpoint_descriptor(iface, 0);
+ if (!ed) {
+ printf("%s: could not read endpoint descriptor\n",
+ device_get_nameunit(sc->sc_dev));
+ return (ENXIO);
+ }
+
+ if (UE_GET_DIR(ed->bEndpointAddress) != UE_DIR_IN ||
+ UE_GET_XFERTYPE(ed->bmAttributes) != UE_INTERRUPT) {
+ printf("%s: unexpected endpoint\n",
+ device_get_nameunit(sc->sc_dev));
+ return (ENXIO);
+ }
+
+ err = usbd_read_report_desc(uaa->iface, &desc, &size, M_TEMP);
+ if (err)
+ return (ENXIO);
+
+ hid_locate(desc, size, 1, hid_input, &a, &flags);
+
+ /* Equal to ums(4). */
+ sc->hw.iftype = MOUSE_IF_USB;
+ sc->hw.type = MOUSE_MOUSE;
+ sc->hw.model = MOUSE_MODEL_GENERIC;
+ sc->hw.hwid = 0;
+ sc->mode.protocol = MOUSE_PROTO_MSC;
+ sc->mode.rate = -1;
+ sc->mode.resolution = MOUSE_RES_UNKNOWN;
+ sc->mode.accelfactor = 0;
+ sc->mode.level = 0;
+ sc->mode.packetsize = MOUSE_MSC_PACKETSIZE;
+ sc->mode.syncmask[0] = MOUSE_MSC_SYNCMASK;
+ sc->mode.syncmask[1] = MOUSE_MSC_SYNC;
+
+ sc->dev = make_dev(&atp_cdevsw, device_get_unit(self),
+ UID_ROOT, GID_OPERATOR,
+ 0644, "atp%d", device_get_unit(self));
+
+
return 0;
}
static int
atp_detach(device_t self)
{
+ struct atp_softc *sc = device_get_softc(self);
+ destroy_dev(sc->dev);
+
return 0;
}
+static void
+atp_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
+{
+
+
+}
+
+static int
+atp_enable(device_t self)
+{
+ struct atp_softc *sc = device_get_softc(self);
+ usbd_status err;
+
+ sc->sc_enabled = 1;
+
+ err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr,
+ USBD_SHORT_XFER_OK, &sc->sc_intrpipe, sc,
+ sc->sc_ibuf, sc->sc_isize, atp_intr,
+ USBD_DEFAULT_INTERVAL);
+ if (err) {
+ device_printf(self, "usb_open_pipe_intr failed with error=%d\n",
+ err);
+ sc->sc_enabled = 0;
+ return (EIO);
+ }
+
+ return (0);
+}
+
+static int
+atp_disable(device_t self)
+{
+ struct atp_softc *sc = device_get_softc(self);
+
+ /* Disable interrupts. */
+ usbd_abort_pipe(sc->sc_intrpipe);
+ usbd_close_pipe(sc->sc_intrpipe);
+
+ sc->sc_enabled = 0;
+}
+
static int
atp_open(struct cdev *dev, int flag, int fmt, struct thread *p)
{
More information about the p4-projects
mailing list