Linux Audio

Check our new training course

Yocto / OpenEmbedded training

Feb 10-13, 2025
Register
Loading...
v4.6
 
  1/*
  2 * USB Empeg empeg-car player driver
  3 *
  4 *	Copyright (C) 2000, 2001
  5 *	    Gary Brubaker (xavyer@ix.netcom.com)
  6 *
  7 *	Copyright (C) 1999 - 2001
  8 *	    Greg Kroah-Hartman (greg@kroah.com)
  9 *
 10 *	This program is free software; you can redistribute it and/or modify
 11 *	it under the terms of the GNU General Public License, as published by
 12 *	the Free Software Foundation, version 2.
 13 *
 14 * See Documentation/usb/usb-serial.txt for more information on using this
 15 * driver
 16 */
 17
 18#include <linux/kernel.h>
 19#include <linux/errno.h>
 20#include <linux/slab.h>
 21#include <linux/tty.h>
 22#include <linux/tty_driver.h>
 23#include <linux/tty_flip.h>
 24#include <linux/module.h>
 25#include <linux/spinlock.h>
 26#include <linux/uaccess.h>
 27#include <linux/usb.h>
 28#include <linux/usb/serial.h>
 29
 30#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
 31#define DRIVER_DESC "USB Empeg Mark I/II Driver"
 32
 33#define EMPEG_VENDOR_ID			0x084f
 34#define EMPEG_PRODUCT_ID		0x0001
 35
 36/* function prototypes for an empeg-car player */
 37static int  empeg_startup(struct usb_serial *serial);
 38static void empeg_init_termios(struct tty_struct *tty);
 39
 40static const struct usb_device_id id_table[] = {
 41	{ USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
 42	{ }					/* Terminating entry */
 43};
 44
 45MODULE_DEVICE_TABLE(usb, id_table);
 46
 47static struct usb_serial_driver empeg_device = {
 48	.driver = {
 49		.owner =	THIS_MODULE,
 50		.name =		"empeg",
 51	},
 52	.id_table =		id_table,
 53	.num_ports =		1,
 54	.bulk_out_size =	256,
 55	.throttle =		usb_serial_generic_throttle,
 56	.unthrottle =		usb_serial_generic_unthrottle,
 57	.attach =		empeg_startup,
 58	.init_termios =		empeg_init_termios,
 59};
 60
 61static struct usb_serial_driver * const serial_drivers[] = {
 62	&empeg_device, NULL
 63};
 64
 65static int empeg_startup(struct usb_serial *serial)
 66{
 67	int r;
 68
 69	if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
 70		dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
 71			serial->dev->actconfig->desc.bConfigurationValue);
 72		return -ENODEV;
 73	}
 74
 75	r = usb_reset_configuration(serial->dev);
 76
 77	/* continue on with initialization */
 78	return r;
 79}
 80
 81static void empeg_init_termios(struct tty_struct *tty)
 82{
 83	struct ktermios *termios = &tty->termios;
 84
 85	/*
 86	 * The empeg-car player wants these particular tty settings.
 87	 * You could, for example, change the baud rate, however the
 88	 * player only supports 115200 (currently), so there is really
 89	 * no point in support for changes to the tty settings.
 90	 * (at least for now)
 91	 *
 92	 * The default requirements for this device are:
 93	 */
 94	termios->c_iflag
 95		&= ~(IGNBRK	/* disable ignore break */
 96		| BRKINT	/* disable break causes interrupt */
 97		| PARMRK	/* disable mark parity errors */
 98		| ISTRIP	/* disable clear high bit of input characters */
 99		| INLCR		/* disable translate NL to CR */
100		| IGNCR		/* disable ignore CR */
101		| ICRNL		/* disable translate CR to NL */
102		| IXON);	/* disable enable XON/XOFF flow control */
103
104	termios->c_oflag
105		&= ~OPOST;	/* disable postprocess output characters */
106
107	termios->c_lflag
108		&= ~(ECHO	/* disable echo input characters */
109		| ECHONL	/* disable echo new line */
110		| ICANON	/* disable erase, kill, werase, and rprnt special characters */
111		| ISIG		/* disable interrupt, quit, and suspend special characters */
112		| IEXTEN);	/* disable non-POSIX special characters */
113
114	termios->c_cflag
115		&= ~(CSIZE	/* no size */
116		| PARENB	/* disable parity bit */
117		| CBAUD);	/* clear current baud rate */
118
119	termios->c_cflag
120		|= CS8;		/* character size 8 bits */
121
122	tty_encode_baud_rate(tty, 115200, 115200);
123}
124
125module_usb_serial_driver(serial_drivers, id_table);
126
127MODULE_AUTHOR(DRIVER_AUTHOR);
128MODULE_DESCRIPTION(DRIVER_DESC);
129MODULE_LICENSE("GPL");
v6.13.7
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * USB Empeg empeg-car player driver
  4 *
  5 *	Copyright (C) 2000, 2001
  6 *	    Gary Brubaker (xavyer@ix.netcom.com)
  7 *
  8 *	Copyright (C) 1999 - 2001
  9 *	    Greg Kroah-Hartman (greg@kroah.com)
 10 *
 11 * See Documentation/usb/usb-serial.rst for more information on using this
 
 
 
 
 12 * driver
 13 */
 14
 15#include <linux/kernel.h>
 16#include <linux/errno.h>
 17#include <linux/slab.h>
 18#include <linux/tty.h>
 19#include <linux/tty_driver.h>
 20#include <linux/tty_flip.h>
 21#include <linux/module.h>
 22#include <linux/spinlock.h>
 23#include <linux/uaccess.h>
 24#include <linux/usb.h>
 25#include <linux/usb/serial.h>
 26
 27#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>"
 28#define DRIVER_DESC "USB Empeg Mark I/II Driver"
 29
 30#define EMPEG_VENDOR_ID			0x084f
 31#define EMPEG_PRODUCT_ID		0x0001
 32
 33/* function prototypes for an empeg-car player */
 34static int  empeg_startup(struct usb_serial *serial);
 35static void empeg_init_termios(struct tty_struct *tty);
 36
 37static const struct usb_device_id id_table[] = {
 38	{ USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
 39	{ }					/* Terminating entry */
 40};
 41
 42MODULE_DEVICE_TABLE(usb, id_table);
 43
 44static struct usb_serial_driver empeg_device = {
 45	.driver = {
 
 46		.name =		"empeg",
 47	},
 48	.id_table =		id_table,
 49	.num_ports =		1,
 50	.bulk_out_size =	256,
 51	.throttle =		usb_serial_generic_throttle,
 52	.unthrottle =		usb_serial_generic_unthrottle,
 53	.attach =		empeg_startup,
 54	.init_termios =		empeg_init_termios,
 55};
 56
 57static struct usb_serial_driver * const serial_drivers[] = {
 58	&empeg_device, NULL
 59};
 60
 61static int empeg_startup(struct usb_serial *serial)
 62{
 63	int r;
 64
 65	if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
 66		dev_err(&serial->dev->dev, "active config #%d != 1 ??\n",
 67			serial->dev->actconfig->desc.bConfigurationValue);
 68		return -ENODEV;
 69	}
 70
 71	r = usb_reset_configuration(serial->dev);
 72
 73	/* continue on with initialization */
 74	return r;
 75}
 76
 77static void empeg_init_termios(struct tty_struct *tty)
 78{
 79	struct ktermios *termios = &tty->termios;
 80
 81	/*
 82	 * The empeg-car player wants these particular tty settings.
 83	 * You could, for example, change the baud rate, however the
 84	 * player only supports 115200 (currently), so there is really
 85	 * no point in support for changes to the tty settings.
 86	 * (at least for now)
 87	 *
 88	 * The default requirements for this device are:
 89	 */
 90	termios->c_iflag
 91		&= ~(IGNBRK	/* disable ignore break */
 92		| BRKINT	/* disable break causes interrupt */
 93		| PARMRK	/* disable mark parity errors */
 94		| ISTRIP	/* disable clear high bit of input characters */
 95		| INLCR		/* disable translate NL to CR */
 96		| IGNCR		/* disable ignore CR */
 97		| ICRNL		/* disable translate CR to NL */
 98		| IXON);	/* disable enable XON/XOFF flow control */
 99
100	termios->c_oflag
101		&= ~OPOST;	/* disable postprocess output characters */
102
103	termios->c_lflag
104		&= ~(ECHO	/* disable echo input characters */
105		| ECHONL	/* disable echo new line */
106		| ICANON	/* disable erase, kill, werase, and rprnt special characters */
107		| ISIG		/* disable interrupt, quit, and suspend special characters */
108		| IEXTEN);	/* disable non-POSIX special characters */
109
110	termios->c_cflag
111		&= ~(CSIZE	/* no size */
112		| PARENB	/* disable parity bit */
113		| CBAUD);	/* clear current baud rate */
114
115	termios->c_cflag
116		|= CS8;		/* character size 8 bits */
117
118	tty_encode_baud_rate(tty, 115200, 115200);
119}
120
121module_usb_serial_driver(serial_drivers, id_table);
122
123MODULE_AUTHOR(DRIVER_AUTHOR);
124MODULE_DESCRIPTION(DRIVER_DESC);
125MODULE_LICENSE("GPL v2");