Re: non-standard baud rates with Prolific 2303 USB-serial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/12/21 8:44 AM, Johan Hovold wrote:

See diff to your branch below.

Unless we do what I originally did and pass 'port'  to pl2303_encode_baud_rate_divisor we cannot test for 'alt_divisor there.

I did this test in pl2303_encode_baud_rate instead so it looks like ...

        if (baud == baud_sup)
                baud = pl2303_encode_baud_rate_direct(buf, baud);
        else if (spriv->type->alt_divisors)
                baud = pl2303_encode_baud_rate_divisor_alt(buf, baud);
        else
                baud = pl2303_encode_baud_rate_divisor(buf, baud);


Michael


191d190
<     unsigned int alt_divisors:1;
221d219
<         .alt_divisors        = true,
226d223
<         .alt_divisors        = true,
625,664d620
< static speed_t pl2303_encode_baud_rate_divisor_alt(unsigned char buf[4],
<                                                                 speed_t baud)
< {
<         unsigned int baseline, mantissa, exponent;
<
<         /*
<          * Apparently, for the TA version the formula is:
<          *   baudrate = 12M * 32 / (mantissa * 2^exponent)
<          * where
<          *   mantissa = buf[10:0]
<          *   exponent = buf[15:13 16]
<          */
<         baseline = 12000000 * 32;
<         mantissa = baseline / baud;
<         if (mantissa == 0)
<                 mantissa = 1;   /* Avoid dividing by zero if baud > 32*12M. */
<         exponent = 0;
<         while (mantissa >= 2048) {
<                 if (exponent < 15) {
<                         mantissa >>= 1; /* divide by 2 */
<                         exponent++;
<                 } else {
<                         /* Exponent is maxed. Trim mantissa and leave. */
<                         mantissa = 2047;
<                         break;
<                 }
<         }
<
<         buf[3] = 0x80;
<         buf[2] = exponent & 0x01; // LS bit of exponent
<         buf[1] = (exponent & ~0x01) << 4 | mantissa >> 8; // 3 bits of the exponent and MS 3 bits of the mantissa
<         buf[0] = mantissa & 0xff; // LS 8 bits of the mantissa
<
<         /* Calculate and return the exact baud rate. */
<         baud = (baseline / mantissa) >> exponent;
<
<         return baud;
< }
<
<
692,693d647
<     else if (spriv->type->alt_divisors)
<                 baud = pl2303_encode_baud_rate_divisor_alt(buf, baud);





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux