All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Serial custom speed deprecated?
@ 2006-08-26 18:16 linux
  2006-08-26 19:37 ` Ian Stirling
  2006-08-28 12:17 ` linux-os (Dick Johnson)
  0 siblings, 2 replies; 54+ messages in thread
From: linux @ 2006-08-26 18:16 UTC (permalink / raw)
  To: linux-kernel

> Or we could just add a standardised extra set of speed ioctls, but then
> we need to decide what occurs if I set the speed and then issue a
> termios call - does it override or not.

Actually, we're not QUITE out of bits.  CBAUDEX | B0 is not taken.
That would make a reasonable encoding for a custom speed.
(But I haven't checked glibc... ah, yes, it should work!
See glibc-2.4/sysdeps/unix/sysv/linux/speed.c; browse at
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/unix/sysv/linux/?cvsroot=glibc
if you don't have a local copy source handy.)

What I'd do is, when converting to the old-style for tcgetattr, if the
current baud rate is not representable, cache it somewhere and return that
(or some other magic value).  If a tcsetatt call comes in that specifies
that magic value, use the cached baud rate.

If you make the cache just the current baud rate setting (the magic
value on set means "don't alter"), that will handle a lot of programs
that just want to play with handshaking.

If you make the cache separate, you can also survive an
old-interface-using program switching to a different baud rate and then
switching back.


Also note that if you truly want to support all baud rates in historical
use, you'll need to include at least one fractional bit for 134.5 baud.
(Unless you're sure that IBM 2741 terminals are truly dead. :-))

Alternatively, you could observe that asynchronous communications only
requires agreement withing 5% between sender and receiver, so specifying
a baud rate to much better than 1% is not too important.

Half-precision floating point would be ideal for the job. :-)

^ permalink raw reply	[flat|nested] 54+ messages in thread
* Re: Serial custom speed deprecated?
@ 2006-08-26 19:35 linux
  0 siblings, 0 replies; 54+ messages in thread
From: linux @ 2006-08-26 19:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: stuartm

> Also, Oxford's 16PCI95x family has three different points of altering
> the clock; the clock prescaler, the actual sample rate (which is the
> classic /16 that most are used to), and the actual divisor. That can
> produce pretty much any baud rate, albeit with some error.

Their data sheet doesn't explain it too well, but it looks like they
use a similar implementation to the MSP430 UARTs, which are designed
to work with very low clock rates.  (32768 Hz watch crystals are
popular.)

Just as a reminder, UART receive operation is generally:
- After detecting a falling edge, wait half a bit time.
- Sample the input 3x and majority-vote.  If the input
  line is still low, call this a start bit and prepare to
  receive a character.
- Wait one bit time, sample 3x, and call the majority the start bit.
- Repeat for all data bits and the stop bit.  If the stop bit isn't
  1 as expected, note a framing error.

This is traditionally done by running a 16x clock sampling the
input, and after detecting a start bit on one clock (call that
clock 0), sample the start bit on clocks 7, 8 and 9, the first bit
on clocks 23, 24 and 25, etc.

MSP430 UARTs have a fully programmable clocks/bit number (no fixed /16,
although you want a few clocks per bit so the standard "sample 3x and
majority vote" algorithm works), and can add +1 clock to individual
bit times to approximate a desired baud rate more closely by dithering.
Oh, and they use both edges of the clock.

So it can go to a baud rate 1/3 of the input baud clock (sample the
start bit at 1, 1.5 and 2 clocks, then the first bit at 4, 4.5 and 5,
etc.), and proceed to 9/24, 10/24, etc.

^ permalink raw reply	[flat|nested] 54+ messages in thread
[parent not found: <6N8LR-22A-5@gated-at.bofh.it>]
* Serial custom speed deprecated?
@ 2006-08-23 21:41 Stuart MacDonald
  2006-08-24  9:18 ` David Woodhouse
  0 siblings, 1 reply; 54+ messages in thread
From: Stuart MacDonald @ 2006-08-23 21:41 UTC (permalink / raw)
  To: 'LKML', dwmw2

From
http://www.kernel.org/pub/linux/kernel/v2.5/ChangeLog-2.5.64

"<dwmw2@dwmw2.baythorne.internal>
	Complain about setting custom speed or divisor on serial ports."

And the relevant patch hunk:
@@ -832,8 +826,17 @@
                goto exit;
        if (info->flags & UIF_INITIALIZED) {
                if (((old_flags ^ port->flags) & UPF_SPD_MASK) ||
-                   old_custom_divisor != port->custom_divisor)
+                   old_custom_divisor != port->custom_divisor) {
+                       /* If they're setting up a custom divisor or speed,
+                        * instead of clearing it, then bitch about it. No
+                        * need to rate-limit; it's CAP_SYS_ADMIN only. */
+                       if (port->flags & UPF_SPD_MASK) {
+                               printk(KERN_NOTICE "%s sets custom speed on %s%d. This is deprecated.\n",
+                                      current->comm, info->tty->driver.name,
+                                      info->port->line);
+                       }
                        uart_change_speed(info, NULL);
+               }
        } else
                retval = uart_startup(info, 1);
  exit:

If custom speeds are deprecated, what's the new method for setting
them? Specifically, how can the SPD_CUST functionality be accomplished
without that flag? I've checked 2.5.64 and 2.6.17, and don't see how
it is possible.

..Stu


^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2006-08-29  7:46 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-26 18:16 Serial custom speed deprecated? linux
2006-08-26 19:37 ` Ian Stirling
2006-08-26 20:30   ` linux
2006-08-28 12:17 ` linux-os (Dick Johnson)
2006-08-28 14:39   ` Alan Cox
2006-08-28 14:50     ` linux-os (Dick Johnson)
2006-08-28 15:51       ` Michael Poole
2006-08-28 16:57         ` linux-os (Dick Johnson)
2006-08-28 17:40           ` Michael Poole
2006-08-28 18:04             ` linux-os (Dick Johnson)
2006-08-28 17:01       ` Alan Cox
2006-08-28 17:24         ` linux
  -- strict thread matches above, loose matches on Subject: below --
2006-08-26 19:35 linux
     [not found] <6N8LR-22A-5@gated-at.bofh.it>
     [not found] ` <6Njxz-797-13@gated-at.bofh.it>
     [not found]   ` <6NqfR-5Ld-49@gated-at.bofh.it>
     [not found]     ` <6NrbQ-7Ab-27@gated-at.bofh.it>
     [not found]       ` <6NsB4-2GL-37@gated-at.bofh.it>
     [not found]         ` <6NvSc-1go-31@gated-at.bofh.it>
2006-08-25 11:40           ` Nick Craig-Wood
2006-08-23 21:41 Stuart MacDonald
2006-08-24  9:18 ` David Woodhouse
2006-08-24 12:41   ` Stuart MacDonald
2006-08-24 13:19     ` Alan Cox
2006-08-24 13:03       ` David Woodhouse
2006-08-24 16:27   ` Krzysztof Halasa
2006-08-24 17:41     ` Alan Cox
2006-08-24 18:51       ` Krzysztof Halasa
2006-08-24 20:43         ` linux-os (Dick Johnson)
2006-08-24 20:43           ` linux-os (Dick Johnson)
2006-08-24 22:11           ` Alan Cox
2006-08-27  6:52             ` Rogier Wolff
2006-08-27  6:52               ` Rogier Wolff
2006-08-27 10:00               ` Russell King
2006-08-28 14:14               ` Stuart MacDonald
2006-08-28 14:14                 ` Stuart MacDonald
2006-08-28 20:09                 ` Russell King
2006-08-29  6:20                   ` Rogier Wolff
2006-08-29  6:20                     ` Rogier Wolff
2006-08-29  7:46                     ` Russell King
2006-08-25 15:17           ` Stuart MacDonald
2006-08-25 15:17             ` Stuart MacDonald
2006-08-25 15:52             ` linux-os (Dick Johnson)
2006-08-25 15:52               ` linux-os (Dick Johnson)
2006-08-24 22:43         ` Alan Cox
2006-08-25 10:58           ` Krzysztof Halasa
2006-08-25 15:21           ` Stuart MacDonald
2006-08-25 15:21             ` Stuart MacDonald
2006-08-25 19:32             ` Russell King
2006-08-25 20:21               ` Stuart MacDonald
2006-08-25 20:21                 ` Stuart MacDonald
2006-08-25 20:54                 ` linux-os (Dick Johnson)
2006-08-25 20:54                   ` linux-os (Dick Johnson)
2006-08-25 20:39               ` Theodore Tso
2006-08-26 12:16                 ` Krzysztof Halasa
2006-08-25 15:10         ` Stuart MacDonald
2006-08-25 15:10           ` Stuart MacDonald
2006-08-24 22:05       ` Russell King
2006-08-25 15:01       ` Stuart MacDonald
2006-08-25 15:01         ` Stuart MacDonald

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.