Guest User

Linux kernel patch for Digidesign Mbox2 frame rate

a guest
Apr 25th, 2017
234
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -ur linux-source-4.8-orig/sound/usb/quirks.c linux-source-4.8-vik/sound/usb/quirks.c
  2. --- linux-source-4.8-orig/sound/usb/quirks.c    2016-12-15 16:50:48.000000000 +0000
  3. +++ linux-source-4.8-vik/sound/usb/quirks.c 2017-04-26 00:03:37.785950373 +0100
  4. @@ -766,28 +766,6 @@
  5.     return -EAGAIN;
  6.  }
  7.  
  8. -static void mbox2_setup_48_24_magic(struct usb_device *dev)
  9. -{
  10. -   u8 srate[3];
  11. -   u8 temp[12];
  12. -
  13. -   /* Choose 48000Hz permanently */
  14. -   srate[0] = 0x80;
  15. -   srate[1] = 0xbb;
  16. -   srate[2] = 0x00;
  17. -
  18. -   /* Send the magic! */
  19. -   snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0),
  20. -       0x01, 0x22, 0x0100, 0x0085, &temp, 0x0003);
  21. -   snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
  22. -       0x81, 0xa2, 0x0100, 0x0085, &srate, 0x0003);
  23. -   snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
  24. -       0x81, 0xa2, 0x0100, 0x0086, &srate, 0x0003);
  25. -   snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
  26. -       0x81, 0xa2, 0x0100, 0x0003, &srate, 0x0003);
  27. -   return;
  28. -}
  29. -
  30.  /* Digidesign Mbox 2 needs to load firmware onboard
  31.   * and driver must wait a few seconds for initialisation.
  32.   */
  33. @@ -845,9 +823,7 @@
  34.     dev_dbg(&dev->dev, "mbox2_boot: new boot length = %d\n",
  35.         le16_to_cpu(get_cfg_desc(config)->wTotalLength));
  36.  
  37. -   mbox2_setup_48_24_magic(dev);
  38. -
  39. -   dev_info(&dev->dev, "Digidesign Mbox 2: 24bit 48kHz");
  40. +   dev_info(&dev->dev, "Digidesign Mbox 2 configured");
  41.  
  42.     return 0; /* Successful boot */
  43.  }
  44. @@ -1111,6 +1087,30 @@
  45.     subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0;
  46.  }
  47.  
  48. +static void set_format_mbox2_quirk(struct snd_usb_substream *subs,
  49. +                struct audioformat *fmt)
  50. +{
  51. +   struct usb_device *dev = subs->dev;
  52. +   u8 data[3];
  53. +   u8 temp[12];
  54. +   int err;
  55. +   int rate = subs->cur_rate;
  56. +
  57. +   dev_info(&subs->dev->dev, "mbox2: set rate to %dHz\n", rate);
  58. +   data[0] = rate;
  59. +   data[1] = rate >> 8;
  60. +   data[2] = rate >> 16;
  61. +
  62. +   /* Forcibly set the sample rate */
  63. +   while ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), UAC_SET_CUR,
  64. +       USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT,
  65. +       UAC_EP_CS_ATTR_SAMPLE_RATE << 8, 0x0085, data, sizeof(data))) < 0)
  66. +       dev_err(&dev->dev, "mbox2: set sample rate failed\n");
  67. +
  68. +   dev_info(&subs->dev->dev, "mbox2: set sample rate to %dHz OK\n", rate);
  69. +   return;
  70. +}
  71. +
  72.  void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
  73.                   struct audioformat *fmt)
  74.  {
  75. @@ -1121,6 +1121,9 @@
  76.     case USB_ID(0x041e, 0x3f19): /* E-Mu 0204 USB */
  77.         set_format_emu_quirk(subs, fmt);
  78.         break;
  79. +   case USB_ID(0x0dba, 0x3000): /* Digidesign Mbox 2 */
  80. +       set_format_mbox2_quirk(subs, fmt);
  81. +       break;
  82.     }
  83.  }
  84.  
  85. diff -ur linux-source-4.8-orig/sound/usb/quirks-table.h linux-source-4.8-vik/sound/usb/quirks-table.h
  86. --- linux-source-4.8-orig/sound/usb/quirks-table.h  2016-12-15 16:50:48.000000000 +0000
  87. +++ linux-source-4.8-vik/sound/usb/quirks-table.h   2017-04-26 00:03:22.260081727 +0100
  88. @@ -3020,12 +3020,13 @@
  89.                     .attributes = 0x00,
  90.                     .endpoint = 0x03,
  91.                     .ep_attr = USB_ENDPOINT_SYNC_ASYNC,
  92. -                   .rates = SNDRV_PCM_RATE_48000,
  93. -                   .rate_min = 48000,
  94. +                   .rates = SNDRV_PCM_RATE_44100|
  95. +                       SNDRV_PCM_RATE_48000,
  96. +                   .rate_min = 44100,
  97.                     .rate_max = 48000,
  98. -                   .nr_rates = 1,
  99. +                   .nr_rates = 2,
  100.                     .rate_table = (unsigned int[]) {
  101. -                       48000
  102. +                       44100, 48000
  103.                     }
  104.                 }
  105.             },
  106. @@ -3045,12 +3046,13 @@
  107.                     .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
  108.                     .endpoint = 0x85,
  109.                     .ep_attr = USB_ENDPOINT_SYNC_SYNC,
  110. -                   .rates = SNDRV_PCM_RATE_48000,
  111. -                   .rate_min = 48000,
  112. +                   .rates = SNDRV_PCM_RATE_44100|
  113. +                       SNDRV_PCM_RATE_48000,
  114. +                   .rate_min = 44100,
  115.                     .rate_max = 48000,
  116. -                   .nr_rates = 1,
  117. +                   .nr_rates = 2,
  118.                     .rate_table = (unsigned int[]) {
  119. -                       48000
  120. +                       44100, 48000
  121.                     }
  122.                 }
  123.             },
RAW Paste Data