2019-05-19 19:08:20 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-01-16 14:58:15 +07:00
|
|
|
/*
|
|
|
|
* radio-aztech.c - Aztech radio card driver
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
2012-01-16 14:58:15 +07:00
|
|
|
* Converted to the radio-isa framework by Hans Verkuil <hans.verkuil@xs4all.nl>
|
MAINTAINERS & files: Canonize the e-mails I use at files
From now on, I'll start using my @kernel.org as my development e-mail.
As such, let's remove the entries that point to the old
mchehab@s-opensource.com at MAINTAINERS file.
For the files written with a copyright with mchehab@s-opensource,
let's keep Samsung on their names, using mchehab+samsung@kernel.org,
in order to keep pointing to my employer, with sponsors the work.
For the files written before I join Samsung (on July, 4 2013),
let's just use mchehab@kernel.org.
For bug reports, we can simply point to just kernel.org, as
this will reach my mchehab+samsung inbox anyway.
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Brian Warner <brian.warner@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-04-25 16:34:48 +07:00
|
|
|
* Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@kernel.org>
|
2006-04-09 02:06:16 +07:00
|
|
|
* Adapted to support the Video for Linux API by
|
2005-04-17 05:20:36 +07:00
|
|
|
* Russell Kroll <rkroll@exploits.org>. Based on original tuner code by:
|
|
|
|
*
|
|
|
|
* Quay Ly
|
|
|
|
* Donald Song
|
2006-04-09 02:06:16 +07:00
|
|
|
* Jason Lewis (jlewis@twilight.vtc.vsc.edu)
|
2005-04-17 05:20:36 +07:00
|
|
|
* Scott McGrath (smcgrath@twilight.vtc.vsc.edu)
|
|
|
|
* William McGrath (wmcgrath@twilight.vtc.vsc.edu)
|
|
|
|
*
|
2012-01-16 14:58:15 +07:00
|
|
|
* Fully tested with the Keene USB FM Transmitter and the v4l2-compliance tool.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2018-01-05 01:08:56 +07:00
|
|
|
#include <linux/module.h> /* Modules */
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/init.h> /* Initdata */
|
2005-09-13 15:25:15 +07:00
|
|
|
#include <linux/ioport.h> /* request_region */
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/delay.h> /* udelay */
|
2006-08-08 19:10:01 +07:00
|
|
|
#include <linux/videodev2.h> /* kernel radio structs */
|
2009-03-06 23:48:18 +07:00
|
|
|
#include <linux/io.h> /* outb, outb_p */
|
2012-02-29 15:50:27 +07:00
|
|
|
#include <linux/slab.h>
|
2009-03-06 23:48:18 +07:00
|
|
|
#include <media/v4l2-device.h>
|
2008-07-20 18:12:02 +07:00
|
|
|
#include <media/v4l2-ioctl.h>
|
2012-01-16 14:58:15 +07:00
|
|
|
#include <media/v4l2-ctrls.h>
|
|
|
|
#include "radio-isa.h"
|
2013-07-19 23:46:17 +07:00
|
|
|
#include "lm7000.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-06 23:48:18 +07:00
|
|
|
MODULE_AUTHOR("Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath");
|
|
|
|
MODULE_DESCRIPTION("A driver for the Aztech radio card.");
|
|
|
|
MODULE_LICENSE("GPL");
|
2012-01-16 14:58:15 +07:00
|
|
|
MODULE_VERSION("1.0.0");
|
2006-08-08 19:10:01 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* acceptable ports: 0x350 (JP3 shorted), 0x358 (JP3 open) */
|
|
|
|
#ifndef CONFIG_RADIO_AZTECH_PORT
|
|
|
|
#define CONFIG_RADIO_AZTECH_PORT -1
|
|
|
|
#endif
|
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
#define AZTECH_MAX 2
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
static int io[AZTECH_MAX] = { [0] = CONFIG_RADIO_AZTECH_PORT,
|
|
|
|
[1 ... (AZTECH_MAX - 1)] = -1 };
|
|
|
|
static int radio_nr[AZTECH_MAX] = { [0 ... (AZTECH_MAX - 1)] = -1 };
|
2009-03-06 23:48:18 +07:00
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
module_param_array(io, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(io, "I/O addresses of the Aztech card (0x350 or 0x358)");
|
|
|
|
module_param_array(radio_nr, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(radio_nr, "Radio device numbers");
|
|
|
|
|
|
|
|
struct aztech {
|
|
|
|
struct radio_isa_card isa;
|
2005-04-17 05:20:36 +07:00
|
|
|
int curvol;
|
|
|
|
};
|
|
|
|
|
2013-07-19 23:46:17 +07:00
|
|
|
/* bit definitions for register read */
|
|
|
|
#define AZTECH_BIT_NOT_TUNED (1 << 0)
|
|
|
|
#define AZTECH_BIT_MONO (1 << 1)
|
|
|
|
/* bit definitions for register write */
|
|
|
|
#define AZTECH_BIT_TUN_CE (1 << 1)
|
|
|
|
#define AZTECH_BIT_TUN_CLK (1 << 6)
|
|
|
|
#define AZTECH_BIT_TUN_DATA (1 << 7)
|
|
|
|
/* bits 0 and 2 are volume control, bits 3..5 are not connected */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-07-19 23:46:17 +07:00
|
|
|
static void aztech_set_pins(void *handle, u8 pins)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-07-19 23:46:17 +07:00
|
|
|
struct radio_isa_card *isa = handle;
|
|
|
|
struct aztech *az = container_of(isa, struct aztech, isa);
|
|
|
|
u8 bits = az->curvol;
|
|
|
|
|
|
|
|
if (pins & LM7000_DATA)
|
|
|
|
bits |= AZTECH_BIT_TUN_DATA;
|
|
|
|
if (pins & LM7000_CLK)
|
|
|
|
bits |= AZTECH_BIT_TUN_CLK;
|
|
|
|
if (pins & LM7000_CE)
|
|
|
|
bits |= AZTECH_BIT_TUN_CE;
|
|
|
|
|
|
|
|
outb_p(bits, az->isa.io);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
static struct radio_isa_card *aztech_alloc(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-01-16 14:58:15 +07:00
|
|
|
struct aztech *az = kzalloc(sizeof(*az), GFP_KERNEL);
|
2009-03-06 23:48:18 +07:00
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
return az ? &az->isa : NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
static int aztech_s_frequency(struct radio_isa_card *isa, u32 freq)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-07-19 23:46:17 +07:00
|
|
|
lm7000_set_freq(freq, isa, aztech_set_pins);
|
2007-01-26 01:10:31 +07:00
|
|
|
|
2007-01-26 02:48:13 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
static u32 aztech_g_rxsubchans(struct radio_isa_card *isa)
|
2009-03-06 23:48:18 +07:00
|
|
|
{
|
2013-07-19 23:46:18 +07:00
|
|
|
if (inb(isa->io) & AZTECH_BIT_MONO)
|
2012-01-16 14:58:15 +07:00
|
|
|
return V4L2_TUNER_SUB_MONO;
|
|
|
|
return V4L2_TUNER_SUB_STEREO;
|
2009-03-06 23:48:18 +07:00
|
|
|
}
|
|
|
|
|
2013-07-19 23:46:18 +07:00
|
|
|
static u32 aztech_g_signal(struct radio_isa_card *isa)
|
2007-01-25 18:09:32 +07:00
|
|
|
{
|
2013-07-19 23:46:18 +07:00
|
|
|
return (inb(isa->io) & AZTECH_BIT_NOT_TUNED) ? 0 : 0xffff;
|
2007-01-25 18:09:32 +07:00
|
|
|
}
|
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
static int aztech_s_mute_volume(struct radio_isa_card *isa, bool mute, int vol)
|
2007-01-25 18:09:32 +07:00
|
|
|
{
|
2012-01-16 14:58:15 +07:00
|
|
|
struct aztech *az = container_of(isa, struct aztech, isa);
|
2007-01-25 18:09:32 +07:00
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
if (mute)
|
|
|
|
vol = 0;
|
|
|
|
az->curvol = (vol & 1) + ((vol & 2) << 1);
|
|
|
|
outb(az->curvol, isa->io);
|
2007-01-25 18:09:32 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
static const struct radio_isa_ops aztech_ops = {
|
|
|
|
.alloc = aztech_alloc,
|
|
|
|
.s_mute_volume = aztech_s_mute_volume,
|
|
|
|
.s_frequency = aztech_s_frequency,
|
|
|
|
.g_rxsubchans = aztech_g_rxsubchans,
|
2013-07-19 23:46:18 +07:00
|
|
|
.g_signal = aztech_g_signal,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2012-01-16 14:58:15 +07:00
|
|
|
static const int aztech_ioports[] = { 0x350, 0x358 };
|
|
|
|
|
|
|
|
static struct radio_isa_driver aztech_driver = {
|
|
|
|
.driver = {
|
|
|
|
.match = radio_isa_match,
|
|
|
|
.probe = radio_isa_probe,
|
|
|
|
.remove = radio_isa_remove,
|
|
|
|
.driver = {
|
|
|
|
.name = "radio-aztech",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.io_params = io,
|
|
|
|
.radio_nr_params = radio_nr,
|
|
|
|
.io_ports = aztech_ioports,
|
|
|
|
.num_of_io_ports = ARRAY_SIZE(aztech_ioports),
|
2013-07-19 23:46:17 +07:00
|
|
|
.region_size = 8,
|
2012-01-16 14:58:15 +07:00
|
|
|
.card = "Aztech Radio",
|
|
|
|
.ops = &aztech_ops,
|
|
|
|
.has_stereo = true,
|
|
|
|
.max_volume = 3,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init aztech_init(void)
|
|
|
|
{
|
2012-01-16 14:58:15 +07:00
|
|
|
return isa_register_driver(&aztech_driver.driver, AZTECH_MAX);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2009-03-06 23:48:18 +07:00
|
|
|
static void __exit aztech_exit(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2012-01-16 14:58:15 +07:00
|
|
|
isa_unregister_driver(&aztech_driver.driver);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(aztech_init);
|
2009-03-06 23:48:18 +07:00
|
|
|
module_exit(aztech_exit);
|