Bug 128485 - [umodem] [patch] Nokia N80 modem support
Summary: [umodem] [patch] Nokia N80 modem support
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 6.3-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-usb (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-30 17:30 UTC by Dron
Modified: 2019-01-24 22:26 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (3.57 KB, patch)
2008-10-30 17:30 UTC, Dron
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dron 2008-10-30 17:30:00 UTC
I have an Nokia N80 smartphone, but in FreeBSD there is no modem were defined, only ugen device...
So I can't use this hardwae to connect to internet...

Fix: after some debug and using google next patch were born:

--- umodem.c.orig       2008-10-22 23:02:46.000000000 +0300
+++ umodem.c.without_debug      2008-10-30 19:04:44.000000000 +0200
@@ -69,6 +69,7 @@
 /*
  * Comm Class spec:  http://www.usb.org/developers/devclass_docs/usbccs10.pdf
  *                   http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
+ *                   http://www.usb.org/developers/devclass_docs/cdc_wmc10.zip
  */

 /*
@@ -127,6 +128,7 @@
        { USB_VENDOR_KYOCERA, USB_PRODUCT_KYOCERA_AHK3001V, 0 },
        { USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720, 0 },
        { USB_VENDOR_CURITEL, USB_PRODUCT_CURITEL_PC5740, 0 },
+       { 0x0421, 0x0445, 0 },
        { 0, 0, 0 },
 };

@@ -179,7 +181,8 @@
                                          usb_cdc_line_state_t *state);

 Static void    umodem_get_caps(usbd_device_handle, int *, int *);
-
+Static usb_cdc_union_descriptor_t  *
+    umodem_get_union(usbd_device_handle dev, int iface_no);
 Static void    umodem_get_status(void *, int portno, u_char *lsr, u_char *msr);
 Static void    umodem_set(void *, int, int, int);
 Static void    umodem_dtr(struct umodem_softc *, int);
@@ -269,7 +272,6 @@

        return ret;
 }
-
 USB_ATTACH(umodem)
 {
        USB_ATTACH_START(umodem, sc, uaa);
@@ -277,6 +279,7 @@
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
        usb_cdc_cm_descriptor_t *cmd;
+        usb_cdc_union_descriptor_t *cud;
        char *devinfo = NULL;
        const char *devname;
        usbd_status err;
@@ -309,10 +312,13 @@
        /* Get the data interface no. */
        cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
        if (cmd == NULL) {
-               printf("%s: no CM descriptor\n", devname);
+                cud = umodem_get_union(dev, sc->sc_ctl_iface_no);
+                if (cud == NULL) {
+                    printf("%s: no CM and Union descriptors\n", devname);
                goto bad;
-       }
-       sc->sc_data_iface_no = data_ifcno = cmd->bDataInterface;
+                }else data_ifcno = cud->bSlaveInterface[0];
+        }else data_ifcno = cmd->bDataInterface;
+        sc->sc_data_iface_no = data_ifcno;

        printf("%s: data interface %d, has %sCM over data, has %sbreak\n",
               devname, data_ifcno,
@@ -558,19 +564,36 @@

        *cm = *acm = 0;

-       cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
-       if (cmd == NULL) {
-               DPRINTF(("umodem_get_desc: no CM desc\n"));
-               return;
-       }
-       *cm = cmd->bmCapabilities;
-
        cad = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_ACM);
        if (cad == NULL) {
                DPRINTF(("umodem_get_desc: no ACM desc\n"));
                return;
        }
        *acm = cad->bmCapabilities;
+
+        cmd = umodem_get_desc(dev, UDESC_CS_INTERFACE, UDESCSUB_CDC_CM);
+        if (cmd == NULL) {
+                DPRINTF(("umodem_get_desc: no CM desc\n"));
+                *cm = USB_CDC_CM_DOES_CM | USB_CDC_CM_OVER_DATA;
+        }else *cm = cmd->bmCapabilities;
+}
+
+usb_cdc_union_descriptor_t  *
+umodem_get_union(usbd_device_handle dev, int iface_no)
+{
+    usb_cdc_union_descriptor_t *desc;
+    usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
+    uByte *p = (uByte *)cd;
+    uByte *end = p + UGETW(cd->wTotalLength);
+    while (p < end) {
+        desc = (usb_cdc_union_descriptor_t *)p;
+        if (desc->bDescriptorType ==  UDESC_CS_INTERFACE &&
+                desc->bDescriptorSubtype == UDESCSUB_CDC_UNION &&
+                desc->bMasterInterface == iface_no)
+            return (desc);
+        p += desc->bLength;
+    }
+    return (0);
 }

 void

With this patch moden is appeared in a system...

Patch attached with submission follows:
How-To-Repeat: install FreeBSD and plug an Nokia N80 :)
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:44 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-24 22:26:01 UTC
UNION support was add in base r189405. Since N80 is arguably rare these days I'm going to close the PR as OBE. If somebody still has the hardware and can verify its functionality with umodem please re-open the issue.