#include "asterisk.h"
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
#include <unistd.h>
#include <sys/io.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/time.h>
#include <stdlib.h>
#include <errno.h>
#include <usb.h>
#include <alsa/asoundlib.h>
#include "./xpmr/xpmr.h"
#include <soundcard.h>
#include "asterisk/lock.h"
#include "asterisk/frame.h"
#include "asterisk/logger.h"
#include "asterisk/callerid.h"
#include "asterisk/channel.h"
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/pbx.h"
#include "asterisk/config.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/endian.h"
#include "asterisk/stringfields.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/musiconhold.h"
#include "asterisk/dsp.h"
#include "./xpmr/xpmr.c"
Go to the source code of this file.
Data Structures | |
struct | chan_usbradio_pvt |
struct | sound |
Defines | |
#define | BOOST_MAX 40 |
#define | BOOST_SCALE (1<<9) |
#define | C108_HID_INTERFACE 3 |
#define | C108_PRODUCT_ID 0x000c |
#define | C108_VENDOR_ID 0x0d8c |
#define | CHAN_USBRADIO 1 |
#define | config1 "usbradio_tune_%s.conf" |
#define | DEBUG_CAP_RX_OUT 0 |
#define | DEBUG_CAP_TX_OUT 0 |
#define | DEBUG_CAPTURES 1 |
#define | DEBUG_FILETEST 0 |
#define | DEBUG_USBRADIO 0 |
#define | DELIMCHR ',' |
#define | DEV_DSP "/dev/dsp" |
#define | EEPROM_CS_ADDR 62 |
#define | EEPROM_END_ADDR 63 |
#define | EEPROM_MAGIC 34329 |
#define | EEPROM_MAGIC_ADDR 6 |
#define | EEPROM_PHYSICAL_LEN 64 |
#define | EEPROM_RXCTCSSADJ 13 |
#define | EEPROM_RXMIXERSET 8 |
#define | EEPROM_RXSQUELCHADJ 16 |
#define | EEPROM_RXVOICEADJ 11 |
#define | EEPROM_START_ADDR 6 |
#define | EEPROM_TEST_ADDR EEPROM_END_ADDR |
#define | EEPROM_TXCTCSSADJ 15 |
#define | EEPROM_TXMIXASET 9 |
#define | EEPROM_TXMIXBSET 10 |
#define | FRAGS ( ( (6 * 5) << 16 ) | 0xc ) |
#define | FRAME_SIZE 160 |
#define | HID_REPORT_GET 0x01 |
#define | HID_REPORT_SET 0x09 |
#define | HID_RT_INPUT 0x01 |
#define | HID_RT_OUTPUT 0x02 |
#define | M_BOOL(tag, dst) M_F(tag, (dst) = ast_true(__val) ) |
#define | M_END(x) x; |
#define | M_F(tag, f) if (!strcasecmp((__s), tag)) { f; } else |
#define | M_START(var, val) char *__s = var; char *__val = val; |
#define | M_STR(tag, dst) M_F(tag, ast_copy_string(dst, __val, sizeof(dst))) |
#define | M_UINT(tag, dst) M_F(tag, (dst) = strtoul(__val, NULL, 0) ) |
#define | MIXER_PARAM_MIC_BOOST "Auto Gain Control" |
#define | MIXER_PARAM_MIC_CAPTURE_SW "Mic Capture Switch" |
#define | MIXER_PARAM_MIC_CAPTURE_VOL "Mic Capture Volume" |
#define | MIXER_PARAM_MIC_PLAYBACK_SW "Mic Playback Switch" |
#define | MIXER_PARAM_MIC_PLAYBACK_VOL "Mic Playback Volume" |
#define | MIXER_PARAM_SPKR_PLAYBACK_SW "Speaker Playback Switch" |
#define | MIXER_PARAM_SPKR_PLAYBACK_VOL "Speaker Playback Volume" |
#define | NEW_ASTERISK |
#define | O_CLOSE 0x444 |
#define | pd(x) {printf(#x" = %d\n",x);} |
#define | pf(x) {printf(#x" = %f\n",x);} |
#define | pp(x) {printf(#x" = %p\n",x);} |
#define | ps(x) {printf(#x" = %s\n",x);} |
#define | QUEUE_SIZE 2 |
#define | QUOTECHR 34 |
#define | READERR_THRESHOLD 50 |
#define | RX_CAP_OUT_FILE "/tmp/rx_cap_out.pcm" |
#define | RX_CAP_RAW_FILE "/tmp/rx_cap_in.pcm" |
#define | RX_CAP_TRACE_FILE "/tmp/rx_trace.pcm" |
#define | TEXT_SIZE 256 |
#define | traceusb1(a) |
#define | traceusb2(a) |
#define | TX_CAP_OUT_FILE "/tmp/tx_cap_out.pcm" |
#define | TX_CAP_RAW_FILE "/tmp/tx_cap_in.pcm" |
#define | TX_CAP_TRACE_FILE "/tmp/tx_trace.pcm" |
#define | WARN_frag 4 |
#define | WARN_speed 2 |
#define | WARN_used_blocks 1 |
Enumerations | |
enum | { RX_AUDIO_NONE, RX_AUDIO_SPEAKER, RX_AUDIO_FLAT } |
enum | { CD_IGNORE, CD_XPMR_NOISE, CD_XPMR_VOX, CD_HID, CD_HID_INVERT } |
enum | { SD_IGNORE, SD_HID, SD_HID_INVERT, SD_XPMR } |
enum | { RX_KEY_CARRIER, RX_KEY_CARRIER_CODE } |
enum | { TX_OUT_OFF, TX_OUT_VOICE, TX_OUT_LSD, TX_OUT_COMPOSITE, TX_OUT_AUX } |
enum | { TOC_NONE, TOC_PHASE, TOC_NOTONE } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | amixer_max (int devnum, char *param) |
static int | console_key (int fd, int argc, char *argv[]) |
static int | console_unkey (int fd, int argc, char *argv[]) |
static struct chan_usbradio_pvt * | find_desc (char *dev) |
static struct chan_usbradio_pvt * | find_desc_usb (char *devstr) |
static unsigned short | get_eeprom (struct usb_dev_handle *handle, unsigned short *buf) |
static char * | handle_console_key (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_console_unkey (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_radio_active (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_radio_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_radio_debug_off (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_radio_tune (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_set_xdebug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static struct usb_device * | hid_device_init (char *desired_device) |
static int | hid_device_mklist (void) |
static void | hid_get_inputs (struct usb_dev_handle *handle, unsigned char *inputs) |
static void | hid_set_outputs (struct usb_dev_handle *handle, unsigned char *outputs) |
static int | hidhdwconfig (struct chan_usbradio_pvt *o) |
static void * | hidthread (void *arg) |
static void | kickptt (struct chan_usbradio_pvt *o) |
static int | load_module (void) |
static void | mixer_write (struct chan_usbradio_pvt *o) |
static int | mult_calc (int value) |
static void | mult_set (struct chan_usbradio_pvt *o) |
static void | pmrdump (struct chan_usbradio_pvt *o) |
static void | put_eeprom (struct usb_dev_handle *handle, unsigned short *buf) |
static int | radio_active (int fd, int argc, char *argv[]) |
static int | radio_set_debug (int fd, int argc, char *argv[]) |
static int | radio_set_debug_off (int fd, int argc, char *argv[]) |
static int | radio_set_xpmr_debug (int fd, int argc, char *argv[]) |
static int | radio_tune (int fd, int argc, char *argv[]) |
static unsigned short | read_eeprom (struct usb_dev_handle *handle, int addr) |
static char * | res2cli (int r) |
static void | ring (struct chan_usbradio_pvt *o, int x) |
static int | set_txctcss_level (struct chan_usbradio_pvt *o) |
static int | setamixer (int devnum, char *param, int v1, int v2) |
static int | setformat (struct chan_usbradio_pvt *o, int mode) |
static int | soundcard_writeframe (struct chan_usbradio_pvt *o, short *data) |
static struct chan_usbradio_pvt * | store_config (struct ast_config *cfg, char *ctg) |
static void | store_rxcdtype (struct chan_usbradio_pvt *o, const char *s) |
static void | store_rxctcssadj (struct chan_usbradio_pvt *o, const char *s) |
static void | store_rxdemod (struct chan_usbradio_pvt *o, const char *s) |
static void | store_rxgain (struct chan_usbradio_pvt *o, const char *s) |
static void | store_rxsdtype (struct chan_usbradio_pvt *o, const char *s) |
static void | store_rxvoiceadj (struct chan_usbradio_pvt *o, const char *s) |
static void | store_txmixa (struct chan_usbradio_pvt *o, const char *s) |
static void | store_txmixb (struct chan_usbradio_pvt *o, const char *s) |
static void | store_txtoctype (struct chan_usbradio_pvt *o, const char *s) |
static void | tune_rxctcss (int fd, struct chan_usbradio_pvt *o) |
static void | tune_rxinput (int fd, struct chan_usbradio_pvt *o) |
static void | tune_rxvoice (int fd, struct chan_usbradio_pvt *o) |
static void | tune_txoutput (struct chan_usbradio_pvt *o, int value, int fd) |
static void | tune_write (struct chan_usbradio_pvt *o) |
static int | unload_module (void) |
static int | usb_get_usbdev (char *devstr) |
static int | usb_list_check (char *devstr) |
static int | usbradio_answer (struct ast_channel *c) |
static int | usbradio_call (struct ast_channel *c, char *dest, int timeout) |
static int | usbradio_digit_begin (struct ast_channel *c, char digit) |
static int | usbradio_digit_end (struct ast_channel *c, char digit, unsigned int duration) |
static int | usbradio_fixup (struct ast_channel *oldchan, struct ast_channel *newchan) |
static int | usbradio_hangup (struct ast_channel *c) |
static int | usbradio_indicate (struct ast_channel *chan, int cond, const void *data, size_t datalen) |
static struct ast_channel * | usbradio_new (struct chan_usbradio_pvt *o, char *ext, char *ctx, int state, const char *linkedid) |
static struct ast_frame * | usbradio_read (struct ast_channel *chan) |
static struct ast_channel * | usbradio_request (const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause) |
static int | usbradio_text (struct ast_channel *c, const char *text) |
static int | usbradio_write (struct ast_channel *chan, struct ast_frame *f) |
static int | used_blocks (struct chan_usbradio_pvt *o) |
static void | write_eeprom (struct usb_dev_handle *handle, int addr, unsigned short data) |
static int | xpmr_config (struct chan_usbradio_pvt *o) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "usb Console Channel Driver" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
static char | active_usage [] |
static struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cli_usbradio [] |
static const char * | config = "usbradio.conf" |
static struct ast_jb_conf | default_jbconf |
static FILE * | frxcapraw = NULL |
static FILE * | frxcaptrace = NULL |
static FILE * | frxoutraw = NULL |
static FILE * | ftxcapraw = NULL |
static FILE * | ftxcaptrace = NULL |
static FILE * | ftxoutraw = NULL |
static struct ast_jb_conf | global_jbconf |
static char | key_usage [] |
static char | radio_tune_usage [] |
static char | tdesc [] = "USB (CM108) Radio Channel Driver" |
static char | unkey_usage [] |
static char * | usb_device_list = NULL |
static int | usb_device_list_size = 0 |
static char * | usbradio_active |
static int | usbradio_debug |
static struct chan_usbradio_pvt | usbradio_default |
static struct ast_channel_tech | usbradio_tech |
Steve Henke <w9sh@arrl.net>
Definition in file chan_usbradio.c.
#define BOOST_MAX 40 |
Definition at line 461 of file chan_usbradio.c.
#define BOOST_SCALE (1<<9) |
Definition at line 460 of file chan_usbradio.c.
#define C108_HID_INTERFACE 3 |
Definition at line 170 of file chan_usbradio.c.
Referenced by hid_get_inputs(), hid_set_outputs(), and hidthread().
#define C108_PRODUCT_ID 0x000c |
Definition at line 169 of file chan_usbradio.c.
Referenced by hid_device_init(), and hid_device_mklist().
#define C108_VENDOR_ID 0x0d8c |
Definition at line 168 of file chan_usbradio.c.
Referenced by hid_device_init(), and hid_device_mklist().
#define CHAN_USBRADIO 1 |
Definition at line 86 of file chan_usbradio.c.
#define config1 "usbradio_tune_%s.conf" |
#define DEBUG_CAP_RX_OUT 0 |
Definition at line 89 of file chan_usbradio.c.
#define DEBUG_CAP_TX_OUT 0 |
Definition at line 90 of file chan_usbradio.c.
#define DEBUG_CAPTURES 1 |
Definition at line 88 of file chan_usbradio.c.
#define DEBUG_FILETEST 0 |
Definition at line 91 of file chan_usbradio.c.
#define DEBUG_USBRADIO 0 |
Definition at line 87 of file chan_usbradio.c.
#define DELIMCHR ',' |
Definition at line 109 of file chan_usbradio.c.
#define DEV_DSP "/dev/dsp" |
Definition at line 357 of file chan_usbradio.c.
#define EEPROM_CS_ADDR 62 |
#define EEPROM_END_ADDR 63 |
#define EEPROM_MAGIC 34329 |
#define EEPROM_MAGIC_ADDR 6 |
#define EEPROM_PHYSICAL_LEN 64 |
Definition at line 180 of file chan_usbradio.c.
#define EEPROM_RXCTCSSADJ 13 |
#define EEPROM_RXMIXERSET 8 |
#define EEPROM_RXSQUELCHADJ 16 |
#define EEPROM_RXVOICEADJ 11 |
#define EEPROM_START_ADDR 6 |
#define EEPROM_TEST_ADDR EEPROM_END_ADDR |
Definition at line 181 of file chan_usbradio.c.
#define EEPROM_TXCTCSSADJ 15 |
#define EEPROM_TXMIXASET 9 |
#define EEPROM_TXMIXBSET 10 |
#define FRAGS ( ( (6 * 5) << 16 ) | 0xc ) |
Definition at line 340 of file chan_usbradio.c.
#define FRAME_SIZE 160 |
Definition at line 334 of file chan_usbradio.c.
#define HID_REPORT_GET 0x01 |
#define HID_REPORT_SET 0x09 |
#define HID_RT_INPUT 0x01 |
#define HID_RT_OUTPUT 0x02 |
#define M_BOOL | ( | tag, | |||
dst | ) | M_F(tag, (dst) = ast_true(__val) ) |
#define M_END | ( | x | ) | x; |
#define M_STR | ( | tag, | |||
dst | ) | M_F(tag, ast_copy_string(dst, __val, sizeof(dst))) |
#define M_UINT | ( | tag, | |||
dst | ) | M_F(tag, (dst) = strtoul(__val, NULL, 0) ) |
#define MIXER_PARAM_MIC_BOOST "Auto Gain Control" |
#define MIXER_PARAM_MIC_CAPTURE_SW "Mic Capture Switch" |
#define MIXER_PARAM_MIC_CAPTURE_VOL "Mic Capture Volume" |
Definition at line 104 of file chan_usbradio.c.
Referenced by mixer_write(), store_config(), and tune_rxinput().
#define MIXER_PARAM_MIC_PLAYBACK_SW "Mic Playback Switch" |
#define MIXER_PARAM_MIC_PLAYBACK_VOL "Mic Playback Volume" |
#define MIXER_PARAM_SPKR_PLAYBACK_SW "Speaker Playback Switch" |
#define MIXER_PARAM_SPKR_PLAYBACK_VOL "Speaker Playback Volume" |
#define NEW_ASTERISK |
Definition at line 1 of file chan_usbradio.c.
#define O_CLOSE 0x444 |
Definition at line 352 of file chan_usbradio.c.
#define pd | ( | x | ) | {printf(#x" = %d\n",x);} |
Definition at line 3150 of file chan_usbradio.c.
Referenced by pcm_write(), playtones_alloc(), and pmrdump().
#define pf | ( | x | ) | {printf(#x" = %f\n",x);} |
#define pp | ( | x | ) | {printf(#x" = %p\n",x);} |
Definition at line 3151 of file chan_usbradio.c.
Referenced by dahdi_setoption(), get_unaligned_uint16(), get_unaligned_uint32(), get_unaligned_uint64(), put_unaligned_uint16(), put_unaligned_uint32(), put_unaligned_uint64(), and sms_readfile().
#define ps | ( | x | ) | {printf(#x" = %s\n",x);} |
Definition at line 3152 of file chan_usbradio.c.
Referenced by playtones_alloc(), playtones_generator(), playtones_release(), and pmrdump().
#define QUEUE_SIZE 2 |
Definition at line 335 of file chan_usbradio.c.
#define QUOTECHR 34 |
Definition at line 110 of file chan_usbradio.c.
#define READERR_THRESHOLD 50 |
#define RX_CAP_OUT_FILE "/tmp/rx_cap_out.pcm" |
#define RX_CAP_RAW_FILE "/tmp/rx_cap_in.pcm" |
#define RX_CAP_TRACE_FILE "/tmp/rx_trace.pcm" |
#define TEXT_SIZE 256 |
Definition at line 347 of file chan_usbradio.c.
#define traceusb1 | ( | a | ) |
#define traceusb2 | ( | a | ) |
Definition at line 129 of file chan_usbradio.c.
Referenced by usbradio_read(), and usbradio_write().
#define TX_CAP_OUT_FILE "/tmp/tx_cap_out.pcm" |
#define TX_CAP_RAW_FILE "/tmp/tx_cap_in.pcm" |
#define TX_CAP_TRACE_FILE "/tmp/tx_trace.pcm" |
#define WARN_frag 4 |
Definition at line 450 of file chan_usbradio.c.
#define WARN_speed 2 |
Definition at line 449 of file chan_usbradio.c.
#define WARN_used_blocks 1 |
Definition at line 448 of file chan_usbradio.c.
anonymous enum |
Definition at line 374 of file chan_usbradio.c.
00374 {RX_AUDIO_NONE,RX_AUDIO_SPEAKER,RX_AUDIO_FLAT};
anonymous enum |
Definition at line 375 of file chan_usbradio.c.
00375 {CD_IGNORE,CD_XPMR_NOISE,CD_XPMR_VOX,CD_HID,CD_HID_INVERT};
anonymous enum |
Definition at line 376 of file chan_usbradio.c.
00376 {SD_IGNORE,SD_HID,SD_HID_INVERT,SD_XPMR}; // no,external,externalinvert,software
anonymous enum |
anonymous enum |
anonymous enum |
static void __reg_module | ( | void | ) | [static] |
Definition at line 4028 of file chan_usbradio.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 4028 of file chan_usbradio.c.
static int amixer_max | ( | int | devnum, | |
char * | param | |||
) | [static] |
Definition at line 712 of file chan_usbradio.c.
Referenced by store_config().
00713 { 00714 int rv,type; 00715 char str[100]; 00716 snd_hctl_t *hctl; 00717 snd_ctl_elem_id_t *id; 00718 snd_hctl_elem_t *elem; 00719 snd_ctl_elem_info_t *info; 00720 00721 sprintf(str,"hw:%d",devnum); 00722 if (snd_hctl_open(&hctl, str, 0)) return(-1); 00723 snd_hctl_load(hctl); 00724 snd_ctl_elem_id_alloca(&id); 00725 snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); 00726 snd_ctl_elem_id_set_name(id, param); 00727 elem = snd_hctl_find_elem(hctl, id); 00728 if (!elem) 00729 { 00730 snd_hctl_close(hctl); 00731 return(-1); 00732 } 00733 snd_ctl_elem_info_alloca(&info); 00734 snd_hctl_elem_info(elem,info); 00735 type = snd_ctl_elem_info_get_type(info); 00736 rv = 0; 00737 switch(type) 00738 { 00739 case SND_CTL_ELEM_TYPE_INTEGER: 00740 rv = snd_ctl_elem_info_get_max(info); 00741 break; 00742 case SND_CTL_ELEM_TYPE_BOOLEAN: 00743 rv = 1; 00744 break; 00745 } 00746 snd_hctl_close(hctl); 00747 return(rv); 00748 }
static int console_key | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 2258 of file chan_usbradio.c.
References find_desc(), RESULT_SHOWUSAGE, RESULT_SUCCESS, chan_usbradio_pvt::txtestkey, and usbradio_active.
Referenced by handle_console_key().
02259 { 02260 struct chan_usbradio_pvt *o = find_desc(usbradio_active); 02261 02262 if (argc != 2) 02263 return RESULT_SHOWUSAGE; 02264 o->txtestkey = 1; 02265 return RESULT_SUCCESS; 02266 }
static int console_unkey | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 2269 of file chan_usbradio.c.
References find_desc(), RESULT_SHOWUSAGE, RESULT_SUCCESS, chan_usbradio_pvt::txtestkey, and usbradio_active.
Referenced by handle_console_unkey().
02270 { 02271 struct chan_usbradio_pvt *o = find_desc(usbradio_active); 02272 02273 if (argc != 2) 02274 return RESULT_SHOWUSAGE; 02275 o->txtestkey = 0; 02276 return RESULT_SUCCESS; 02277 }
static struct chan_usbradio_pvt* find_desc | ( | char * | dev | ) | [static] |
Definition at line 1255 of file chan_usbradio.c.
References ast_log(), LOG_WARNING, chan_usbradio_pvt::name, chan_usbradio_pvt::next, and usbradio_default.
01256 { 01257 struct chan_usbradio_pvt *o = NULL; 01258 01259 if (!dev) 01260 ast_log(LOG_WARNING, "null dev\n"); 01261 01262 for (o = usbradio_default.next; o && o->name && dev && strcmp(o->name, dev) != 0; o = o->next); 01263 if (!o) 01264 { 01265 ast_log(LOG_WARNING, "could not find <%s>\n", dev ? dev : "--no-device--"); 01266 } 01267 01268 return o; 01269 }
static struct chan_usbradio_pvt* find_desc_usb | ( | char * | devstr | ) | [static] |
Definition at line 1271 of file chan_usbradio.c.
References ast_log(), chan_usbradio_pvt::devstr, LOG_WARNING, chan_usbradio_pvt::next, and usbradio_default.
Referenced by store_config().
01272 { 01273 struct chan_usbradio_pvt *o = NULL; 01274 01275 if (!devstr) 01276 ast_log(LOG_WARNING, "null dev\n"); 01277 01278 for (o = usbradio_default.next; o && devstr && strcmp(o->devstr, devstr) != 0; o = o->next); 01279 01280 return o; 01281 }
static unsigned short get_eeprom | ( | struct usb_dev_handle * | handle, | |
unsigned short * | buf | |||
) | [static] |
Definition at line 853 of file chan_usbradio.c.
References EEPROM_END_ADDR, EEPROM_START_ADDR, and read_eeprom().
Referenced by hidthread().
00855 { 00856 int i; 00857 unsigned short cs; 00858 00859 cs = 0xffff; 00860 for(i = EEPROM_START_ADDR; i < EEPROM_END_ADDR; i++) 00861 { 00862 cs += buf[i] = read_eeprom(handle,i); 00863 } 00864 return(cs); 00865 }
static char* handle_console_key | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 3809 of file chan_usbradio.c.
References CLI_GENERATE, CLI_INIT, ast_cli_entry::command, console_key(), ast_cli_args::fd, res2cli(), and ast_cli_entry::usage.
03811 { 03812 char *argv[] = { "radio", "key", NULL }; 03813 03814 switch (cmd) { 03815 case CLI_INIT: 03816 e->command = "radio key"; 03817 e->usage = key_usage; 03818 return NULL; 03819 case CLI_GENERATE: 03820 return NULL; 03821 } 03822 return res2cli(console_key(a->fd, 2, argv)); 03823 }
static char* handle_console_unkey | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 3825 of file chan_usbradio.c.
References CLI_GENERATE, CLI_INIT, ast_cli_entry::command, console_unkey(), ast_cli_args::fd, res2cli(), and ast_cli_entry::usage.
03827 { 03828 char *argv[] = { "radio", "unkey", NULL }; 03829 switch (cmd) { 03830 case CLI_INIT: 03831 e->command = "radio unkey"; 03832 e->usage = unkey_usage; 03833 return NULL; 03834 case CLI_GENERATE: 03835 return NULL; 03836 } 03837 return res2cli(console_unkey(a->fd, 2, argv)); 03838 }
static char* handle_radio_active | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 3883 of file chan_usbradio.c.
References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, radio_active(), res2cli(), and ast_cli_entry::usage.
03885 { 03886 char *argv[4] = { "radio", "active", a->argc > 2 ? (char *) a->argv[2] : NULL, }; 03887 switch (cmd) { 03888 case CLI_INIT: 03889 e->command = "radio active"; 03890 e->usage = active_usage; 03891 return NULL; 03892 case CLI_GENERATE: 03893 return NULL; 03894 } 03895 return res2cli(radio_active(a->fd, a->argc, argv)); 03896 }
static char* handle_radio_debug | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 3855 of file chan_usbradio.c.
References ast_cli_args::argc, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, radio_set_debug(), res2cli(), and ast_cli_entry::usage.
03857 { 03858 switch (cmd) { 03859 case CLI_INIT: 03860 e->command = "radio debug"; 03861 e->usage = radio_tune_usage; 03862 return NULL; 03863 case CLI_GENERATE: 03864 return NULL; 03865 } 03866 return res2cli(radio_set_debug(a->fd, a->argc, NULL /* ignored */)); 03867 }
static char* handle_radio_debug_off | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 3869 of file chan_usbradio.c.
References ast_cli_args::argc, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, radio_set_debug_off(), res2cli(), and ast_cli_entry::usage.
03871 { 03872 switch (cmd) { 03873 case CLI_INIT: 03874 e->command = "radio debug off"; 03875 e->usage = radio_tune_usage; 03876 return NULL; 03877 case CLI_GENERATE: 03878 return NULL; 03879 } 03880 return res2cli(radio_set_debug_off(a->fd, a->argc, NULL /* ignored */)); 03881 }
static char* handle_radio_tune | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 3840 of file chan_usbradio.c.
References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, radio_tune(), res2cli(), and ast_cli_entry::usage.
03842 { 03843 char *argv[5] = { "radio", "tune", a->argc > 2 ? (char *) a->argv[2] : NULL, a->argc > 3 ? (char *) a->argv[3] : NULL }; 03844 switch (cmd) { 03845 case CLI_INIT: 03846 e->command = "radio tune"; 03847 e->usage = radio_tune_usage; 03848 return NULL; 03849 case CLI_GENERATE: 03850 return NULL; 03851 } 03852 return res2cli(radio_tune(a->fd, a->argc, argv)); 03853 }
static char* handle_set_xdebug | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 3898 of file chan_usbradio.c.
References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, radio_set_xpmr_debug(), res2cli(), and ast_cli_entry::usage.
03900 { 03901 char *argv[5] = { "radio", "set", "xdebug", a->argc == 4 ? (char *) a->argv[3] : NULL, }; 03902 switch (cmd) { 03903 case CLI_INIT: 03904 e->command = "radio set xdebug"; 03905 e->usage = active_usage; 03906 return NULL; 03907 case CLI_GENERATE: 03908 return NULL; 03909 } 03910 return res2cli(radio_set_xpmr_debug(a->fd, a->argc, argv)); 03911 }
static struct usb_device* hid_device_init | ( | char * | desired_device | ) | [static] |
Definition at line 883 of file chan_usbradio.c.
References C108_PRODUCT_ID, C108_VENDOR_ID, and str.
Referenced by hidthread().
00884 { 00885 struct usb_bus *usb_bus; 00886 struct usb_device *dev; 00887 char devstr[200],str[200],desdev[200],*cp; 00888 int i; 00889 FILE *fp; 00890 00891 usb_init(); 00892 usb_find_busses(); 00893 usb_find_devices(); 00894 for (usb_bus = usb_busses; 00895 usb_bus; 00896 usb_bus = usb_bus->next) { 00897 for (dev = usb_bus->devices; 00898 dev; 00899 dev = dev->next) { 00900 if ((dev->descriptor.idVendor 00901 == C108_VENDOR_ID) && 00902 (dev->descriptor.idProduct 00903 == C108_PRODUCT_ID)) 00904 { 00905 sprintf(devstr,"%s/%s", usb_bus->dirname,dev->filename); 00906 for(i = 0; i < 32; i++) 00907 { 00908 sprintf(str,"/proc/asound/card%d/usbbus",i); 00909 fp = fopen(str,"r"); 00910 if (!fp) continue; 00911 if ((!fgets(desdev,sizeof(desdev) - 1,fp)) || (!desdev[0])) 00912 { 00913 fclose(fp); 00914 continue; 00915 } 00916 fclose(fp); 00917 if (desdev[strlen(desdev) - 1] == '\n') 00918 desdev[strlen(desdev) -1 ] = 0; 00919 if (strcasecmp(desdev,devstr)) continue; 00920 if (i) sprintf(str,"/sys/class/sound/dsp%d/device",i); 00921 else strcpy(str,"/sys/class/sound/dsp/device"); 00922 memset(desdev,0,sizeof(desdev)); 00923 if (readlink(str,desdev,sizeof(desdev) - 1) == -1) 00924 { 00925 sprintf(str,"/sys/class/sound/controlC%d/device",i); 00926 memset(desdev,0,sizeof(desdev)); 00927 if (readlink(str,desdev,sizeof(desdev) - 1) == -1) continue; 00928 } 00929 cp = strrchr(desdev,'/'); 00930 if (cp) *cp = 0; else continue; 00931 cp = strrchr(desdev,'/'); 00932 if (!cp) continue; 00933 cp++; 00934 break; 00935 } 00936 if (i >= 32) continue; 00937 if (!strcmp(cp,desired_device)) return dev; 00938 } 00939 00940 } 00941 } 00942 return NULL; 00943 }
static int hid_device_mklist | ( | void | ) | [static] |
Definition at line 945 of file chan_usbradio.c.
References ast_malloc, ast_realloc, C108_PRODUCT_ID, C108_VENDOR_ID, and str.
Referenced by load_module().
00946 { 00947 struct usb_bus *usb_bus; 00948 struct usb_device *dev; 00949 char devstr[200],str[200],desdev[200],*cp; 00950 int i; 00951 FILE *fp; 00952 00953 usb_device_list = ast_malloc(2); 00954 if (!usb_device_list) return -1; 00955 memset(usb_device_list,0,2); 00956 00957 usb_init(); 00958 usb_find_busses(); 00959 usb_find_devices(); 00960 for (usb_bus = usb_busses; 00961 usb_bus; 00962 usb_bus = usb_bus->next) { 00963 for (dev = usb_bus->devices; 00964 dev; 00965 dev = dev->next) { 00966 if ((dev->descriptor.idVendor 00967 == C108_VENDOR_ID) && 00968 (dev->descriptor.idProduct 00969 == C108_PRODUCT_ID)) 00970 { 00971 sprintf(devstr,"%s/%s", usb_bus->dirname,dev->filename); 00972 for(i = 0;i < 32; i++) 00973 { 00974 sprintf(str,"/proc/asound/card%d/usbbus",i); 00975 fp = fopen(str,"r"); 00976 if (!fp) continue; 00977 if ((!fgets(desdev,sizeof(desdev) - 1,fp)) || (!desdev[0])) 00978 { 00979 fclose(fp); 00980 continue; 00981 } 00982 fclose(fp); 00983 if (desdev[strlen(desdev) - 1] == '\n') 00984 desdev[strlen(desdev) -1 ] = 0; 00985 if (strcasecmp(desdev,devstr)) continue; 00986 if (i) sprintf(str,"/sys/class/sound/dsp%d/device",i); 00987 else strcpy(str,"/sys/class/sound/dsp/device"); 00988 memset(desdev,0,sizeof(desdev)); 00989 if (readlink(str,desdev,sizeof(desdev) - 1) == -1) 00990 { 00991 sprintf(str,"/sys/class/sound/controlC%d/device",i); 00992 memset(desdev,0,sizeof(desdev)); 00993 if (readlink(str,desdev,sizeof(desdev) - 1) == -1) continue; 00994 } 00995 cp = strrchr(desdev,'/'); 00996 if (cp) *cp = 0; else continue; 00997 cp = strrchr(desdev,'/'); 00998 if (!cp) continue; 00999 cp++; 01000 break; 01001 } 01002 if (i >= 32) return -1; 01003 usb_device_list = ast_realloc(usb_device_list, 01004 usb_device_list_size + 2 + 01005 strlen(cp)); 01006 if (!usb_device_list) return -1; 01007 usb_device_list_size += strlen(cp) + 2; 01008 i = 0; 01009 while(usb_device_list[i]) 01010 { 01011 i += strlen(usb_device_list + i) + 1; 01012 } 01013 strcat(usb_device_list + i,cp); 01014 usb_device_list[strlen(cp) + i + 1] = 0; 01015 } 01016 01017 } 01018 } 01019 return 0; 01020 }
static void hid_get_inputs | ( | struct usb_dev_handle * | handle, | |
unsigned char * | inputs | |||
) | [static] |
Definition at line 814 of file chan_usbradio.c.
References C108_HID_INTERFACE, HID_REPORT_GET, and HID_RT_INPUT.
Referenced by hidthread(), and read_eeprom().
00816 { 00817 usleep(1500); 00818 usb_control_msg(handle, 00819 USB_ENDPOINT_IN + USB_TYPE_CLASS + USB_RECIP_INTERFACE, 00820 HID_REPORT_GET, 00821 0 + (HID_RT_INPUT << 8), 00822 C108_HID_INTERFACE, 00823 (char*)inputs, 4, 5000); 00824 }
static void hid_set_outputs | ( | struct usb_dev_handle * | handle, | |
unsigned char * | outputs | |||
) | [static] |
Definition at line 802 of file chan_usbradio.c.
References C108_HID_INTERFACE, HID_REPORT_SET, and HID_RT_OUTPUT.
Referenced by hidthread(), read_eeprom(), and write_eeprom().
00804 { 00805 usleep(1500); 00806 usb_control_msg(handle, 00807 USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, 00808 HID_REPORT_SET, 00809 0 + (HID_RT_OUTPUT << 8), 00810 C108_HID_INTERFACE, 00811 (char*)outputs, 4, 5000); 00812 }
static int hidhdwconfig | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 1066 of file chan_usbradio.c.
References chan_usbradio_pvt::hdwtype, chan_usbradio_pvt::hid_gpio_ctl, chan_usbradio_pvt::hid_gpio_ctl_loc, chan_usbradio_pvt::hid_gpio_loc, chan_usbradio_pvt::hid_io_cor, chan_usbradio_pvt::hid_io_cor_loc, chan_usbradio_pvt::hid_io_ctcss, chan_usbradio_pvt::hid_io_ctcss_loc, and chan_usbradio_pvt::hid_io_ptt.
Referenced by store_config().
01067 { 01068 if(o->hdwtype==1) //sphusb 01069 { 01070 o->hid_gpio_ctl = 0x08; /* set GPIO4 to output mode */ 01071 o->hid_gpio_ctl_loc = 2; /* For CTL of GPIO */ 01072 o->hid_io_cor = 4; /* GPIO3 is COR */ 01073 o->hid_io_cor_loc = 1; /* GPIO3 is COR */ 01074 o->hid_io_ctcss = 2; /* GPIO 2 is External CTCSS */ 01075 o->hid_io_ctcss_loc = 1; /* is GPIO 2 */ 01076 o->hid_io_ptt = 8; /* GPIO 4 is PTT */ 01077 o->hid_gpio_loc = 1; /* For ALL GPIO */ 01078 } 01079 else if(o->hdwtype==0) //dudeusb 01080 { 01081 o->hid_gpio_ctl = 0x0c; /* set GPIO 3 & 4 to output mode */ 01082 o->hid_gpio_ctl_loc = 2; /* For CTL of GPIO */ 01083 o->hid_io_cor = 2; /* VOLD DN is COR */ 01084 o->hid_io_cor_loc = 0; /* VOL DN COR */ 01085 o->hid_io_ctcss = 2; /* GPIO 2 is External CTCSS */ 01086 o->hid_io_ctcss_loc = 1; /* is GPIO 2 */ 01087 o->hid_io_ptt = 4; /* GPIO 3 is PTT */ 01088 o->hid_gpio_loc = 1; /* For ALL GPIO */ 01089 } 01090 else if(o->hdwtype==3) // custom version 01091 { 01092 o->hid_gpio_ctl = 0x0c; /* set GPIO 3 & 4 to output mode */ 01093 o->hid_gpio_ctl_loc = 2; /* For CTL of GPIO */ 01094 o->hid_io_cor = 2; /* VOLD DN is COR */ 01095 o->hid_io_cor_loc = 0; /* VOL DN COR */ 01096 o->hid_io_ctcss = 2; /* GPIO 2 is External CTCSS */ 01097 o->hid_io_ctcss_loc = 1; /* is GPIO 2 */ 01098 o->hid_io_ptt = 4; /* GPIO 3 is PTT */ 01099 o->hid_gpio_loc = 1; /* For ALL GPIO */ 01100 } 01101 01102 return 0; 01103 }
static void* hidthread | ( | void * | arg | ) | [static] |
Definition at line 1118 of file chan_usbradio.c.
References ast_debug, ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_poll, C108_HID_INTERFACE, chan_usbradio_pvt::debuglevel, chan_usbradio_pvt::devstr, chan_usbradio_pvt::eeprom, EEPROM_MAGIC, EEPROM_MAGIC_ADDR, EEPROM_RXCTCSSADJ, EEPROM_RXMIXERSET, EEPROM_RXSQUELCHADJ, EEPROM_RXVOICEADJ, EEPROM_TXCTCSSADJ, EEPROM_TXMIXASET, EEPROM_TXMIXBSET, chan_usbradio_pvt::eepromctl, chan_usbradio_pvt::eepromlock, errno, get_eeprom(), hid_device_init(), hid_get_inputs(), chan_usbradio_pvt::hid_gpio_ctl, chan_usbradio_pvt::hid_gpio_ctl_loc, chan_usbradio_pvt::hid_gpio_loc, chan_usbradio_pvt::hid_io_cor, chan_usbradio_pvt::hid_io_cor_loc, chan_usbradio_pvt::hid_io_ptt, hid_set_outputs(), chan_usbradio_pvt::invertptt, chan_usbradio_pvt::lasthidtime, chan_usbradio_pvt::lasttx, LOG_ERROR, LOG_NOTICE, LOG_WARNING, chan_usbradio_pvt::name, chan_usbradio_pvt::pmrChan, chan_usbradio_pvt::pttkick, put_eeprom(), chan_usbradio_pvt::rxctcssadj, chan_usbradio_pvt::rxhidsq, chan_usbradio_pvt::rxmixerset, chan_usbradio_pvt::rxsquelchadj, chan_usbradio_pvt::rxvoiceadj, chan_usbradio_pvt::stophid, traceusb1, chan_usbradio_pvt::txctcssadj, chan_usbradio_pvt::txmixaset, chan_usbradio_pvt::txmixbset, and chan_usbradio_pvt::wanteeprom.
Referenced by usbradio_call().
01119 { 01120 unsigned char buf[4],bufsave[4],keyed; 01121 char lastrx, txtmp; 01122 int res; 01123 struct usb_device *usb_dev; 01124 struct usb_dev_handle *usb_handle; 01125 struct chan_usbradio_pvt *o = (struct chan_usbradio_pvt *) arg; 01126 struct pollfd pfd = { .events = POLLIN }; 01127 01128 usb_dev = hid_device_init(o->devstr); 01129 if (usb_dev == NULL) { 01130 ast_log(LOG_ERROR,"USB HID device not found\n"); 01131 pthread_exit(NULL); 01132 } 01133 usb_handle = usb_open(usb_dev); 01134 if (usb_handle == NULL) { 01135 ast_log(LOG_ERROR,"Not able to open USB device\n"); 01136 pthread_exit(NULL); 01137 } 01138 if (usb_claim_interface(usb_handle,C108_HID_INTERFACE) < 0) 01139 { 01140 if (usb_detach_kernel_driver_np(usb_handle,C108_HID_INTERFACE) < 0) { 01141 ast_log(LOG_ERROR,"Not able to detach the USB device\n"); 01142 pthread_exit(NULL); 01143 } 01144 if (usb_claim_interface(usb_handle,C108_HID_INTERFACE) < 0) { 01145 ast_log(LOG_ERROR,"Not able to claim the USB device\n"); 01146 pthread_exit(NULL); 01147 } 01148 } 01149 memset(buf,0,sizeof(buf)); 01150 buf[2] = o->hid_gpio_ctl; 01151 buf[1] = 0; 01152 hid_set_outputs(usb_handle,buf); 01153 memcpy(bufsave,buf,sizeof(buf)); 01154 if (pipe(o->pttkick) == -1) 01155 { 01156 ast_log(LOG_ERROR,"Not able to create pipe\n"); 01157 pthread_exit(NULL); 01158 } 01159 traceusb1(("hidthread: Starting normally on %s!!\n",o->name)); 01160 lastrx = 0; 01161 // popen 01162 while (!o->stophid) { 01163 pfd.fd = o->pttkick[0]; 01164 pfd.revents = 0; 01165 01166 res = ast_poll(&pfd, 1, 50); 01167 if (res < 0) { 01168 ast_log(LOG_WARNING, "poll() failed: %s\n", strerror(errno)); 01169 usleep(10000); 01170 continue; 01171 } 01172 if (pfd.revents & POLLIN) { 01173 char c; 01174 01175 if (read(o->pttkick[0], &c, 1) < 0) { 01176 ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno)); 01177 } 01178 } 01179 if (o->wanteeprom) { 01180 ast_mutex_lock(&o->eepromlock); 01181 if (o->eepromctl == 1) { /* to read */ 01182 /* if CS okay */ 01183 if (!get_eeprom(usb_handle, o->eeprom)) { 01184 if (o->eeprom[EEPROM_MAGIC_ADDR] != EEPROM_MAGIC) { 01185 ast_log(LOG_NOTICE, "UNSUCCESSFUL: EEPROM MAGIC NUMBER BAD on channel %s\n", o->name); 01186 } else { 01187 o->rxmixerset = o->eeprom[EEPROM_RXMIXERSET]; 01188 o->txmixaset = o->eeprom[EEPROM_TXMIXASET]; 01189 o->txmixbset = o->eeprom[EEPROM_TXMIXBSET]; 01190 memcpy(&o->rxvoiceadj, &o->eeprom[EEPROM_RXVOICEADJ], sizeof(float)); 01191 memcpy(&o->rxctcssadj, &o->eeprom[EEPROM_RXCTCSSADJ], sizeof(float)); 01192 o->txctcssadj = o->eeprom[EEPROM_TXCTCSSADJ]; 01193 o->rxsquelchadj = o->eeprom[EEPROM_RXSQUELCHADJ]; 01194 ast_log(LOG_NOTICE,"EEPROM Loaded on channel %s\n",o->name); 01195 } 01196 } else { 01197 ast_log(LOG_NOTICE, "USB Adapter has no EEPROM installed or Checksum BAD on channel %s\n", o->name); 01198 } 01199 hid_set_outputs(usb_handle,bufsave); 01200 } 01201 if (o->eepromctl == 2) { /* to write */ 01202 put_eeprom(usb_handle,o->eeprom); 01203 hid_set_outputs(usb_handle,bufsave); 01204 ast_log(LOG_NOTICE, "USB Parameters written to EEPROM on %s\n", o->name); 01205 } 01206 o->eepromctl = 0; 01207 ast_mutex_unlock(&o->eepromlock); 01208 } 01209 buf[o->hid_gpio_ctl_loc] = o->hid_gpio_ctl; 01210 hid_get_inputs(usb_handle,buf); 01211 keyed = !(buf[o->hid_io_cor_loc] & o->hid_io_cor); 01212 if (keyed != o->rxhidsq) { 01213 if (o->debuglevel) { 01214 printf("chan_usbradio() hidthread: update rxhidsq = %d\n", keyed); 01215 } 01216 o->rxhidsq=keyed; 01217 } 01218 01219 /* if change in tx state as controlled by xpmr */ 01220 txtmp = o->pmrChan->txPttOut; 01221 01222 if (o->lasttx != txtmp) { 01223 o->pmrChan->txPttHid = o->lasttx = txtmp; 01224 if (o->debuglevel) { 01225 ast_debug(0, "hidthread: tx set to %d\n", txtmp); 01226 } 01227 buf[o->hid_gpio_loc] = 0; 01228 if (!o->invertptt) { 01229 if (txtmp) { 01230 buf[o->hid_gpio_loc] = o->hid_io_ptt; 01231 } 01232 } else { 01233 if (!txtmp) { 01234 buf[o->hid_gpio_loc] = o->hid_io_ptt; 01235 } 01236 } 01237 buf[o->hid_gpio_ctl_loc] = o->hid_gpio_ctl; 01238 memcpy(bufsave, buf, sizeof(buf)); 01239 hid_set_outputs(usb_handle, buf); 01240 } 01241 time(&o->lasthidtime); 01242 } 01243 buf[o->hid_gpio_loc] = 0; 01244 if (o->invertptt) { 01245 buf[o->hid_gpio_loc] = o->hid_io_ptt; 01246 } 01247 buf[o->hid_gpio_ctl_loc] = o->hid_gpio_ctl; 01248 hid_set_outputs(usb_handle, buf); 01249 pthread_exit(0); 01250 }
static void kickptt | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 1106 of file chan_usbradio.c.
References ast_log(), errno, LOG_ERROR, and chan_usbradio_pvt::pttkick.
Referenced by usbradio_read().
01107 { 01108 char c = 0; 01109 //printf("kickptt %i %i %i\n",o->txkeyed,o->txchankey,o->txtestkey); 01110 if (!o) return; 01111 if (!o->pttkick) return; 01112 if (write(o->pttkick[1],&c,1) < 0) { 01113 ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno)); 01114 } 01115 }
static int load_module | ( | void | ) | [static] |
Definition at line 3933 of file chan_usbradio.c.
References ARRAY_LEN, ast_category_browse(), ast_channel_register(), ast_cli_register_multiple(), ast_config_destroy(), ast_config_load, ast_log(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, cli_usbradio, config, CONFIG_STATUS_FILEINVALID, default_jbconf, find_desc(), global_jbconf, hid_device_mklist(), LOG_ERROR, LOG_NOTICE, store_config(), usb_list_check(), usbradio_active, and usbradio_tech.
03934 { 03935 struct ast_config *cfg = NULL; 03936 char *ctg = NULL; 03937 #ifdef NEW_ASTERISK 03938 struct ast_flags zeroflag = {0}; 03939 #endif 03940 03941 if (hid_device_mklist()) { 03942 ast_log(LOG_NOTICE, "Unable to make hid list\n"); 03943 return AST_MODULE_LOAD_DECLINE; 03944 } 03945 03946 usb_list_check(""); 03947 03948 usbradio_active = NULL; 03949 03950 /* Copy the default jb config over global_jbconf */ 03951 memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); 03952 03953 /* load config file */ 03954 #ifdef NEW_ASTERISK 03955 if (!(cfg = ast_config_load(config,zeroflag)) || cfg == CONFIG_STATUS_FILEINVALID) { 03956 #else 03957 if (!(cfg = ast_config_load(config))) || cfg == CONFIG_STATUS_FILEINVALID { 03958 #endif 03959 ast_log(LOG_NOTICE, "Unable to load config %s\n", config); 03960 return AST_MODULE_LOAD_DECLINE; 03961 } 03962 03963 do { 03964 store_config(cfg, ctg); 03965 } while ( (ctg = ast_category_browse(cfg, ctg)) != NULL); 03966 03967 ast_config_destroy(cfg); 03968 03969 if (find_desc(usbradio_active) == NULL) { 03970 ast_log(LOG_NOTICE, "radio active device %s not found\n", usbradio_active); 03971 /* XXX we could default to 'dsp' perhaps ? */ 03972 /* XXX should cleanup allocated memory etc. */ 03973 return AST_MODULE_LOAD_DECLINE; 03974 } 03975 03976 if (ast_channel_register(&usbradio_tech)) { 03977 ast_log(LOG_ERROR, "Unable to register channel type 'usb'\n"); 03978 return AST_MODULE_LOAD_DECLINE; 03979 } 03980 03981 ast_cli_register_multiple(cli_usbradio, ARRAY_LEN(cli_usbradio)); 03982 03983 return AST_MODULE_LOAD_SUCCESS; 03984 }
static void mixer_write | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 3109 of file chan_usbradio.c.
References chan_usbradio_pvt::devicenum, chan_usbradio_pvt::micmax, MIXER_PARAM_MIC_BOOST, MIXER_PARAM_MIC_CAPTURE_SW, MIXER_PARAM_MIC_CAPTURE_VOL, MIXER_PARAM_MIC_PLAYBACK_SW, MIXER_PARAM_MIC_PLAYBACK_VOL, MIXER_PARAM_SPKR_PLAYBACK_SW, MIXER_PARAM_SPKR_PLAYBACK_VOL, chan_usbradio_pvt::rxboostset, chan_usbradio_pvt::rxmixerset, setamixer(), chan_usbradio_pvt::spkrmax, chan_usbradio_pvt::txmixaset, and chan_usbradio_pvt::txmixbset.
Referenced by radio_tune(), set_txctcss_level(), and store_config().
03110 { 03111 setamixer(o->devicenum,MIXER_PARAM_MIC_PLAYBACK_SW,0,0); 03112 setamixer(o->devicenum,MIXER_PARAM_MIC_PLAYBACK_VOL,0,0); 03113 setamixer(o->devicenum,MIXER_PARAM_SPKR_PLAYBACK_SW,1,0); 03114 setamixer(o->devicenum,MIXER_PARAM_SPKR_PLAYBACK_VOL, 03115 o->txmixaset * o->spkrmax / 1000, 03116 o->txmixbset * o->spkrmax / 1000); 03117 setamixer(o->devicenum,MIXER_PARAM_MIC_CAPTURE_VOL, 03118 o->rxmixerset * o->micmax / 1000,0); 03119 setamixer(o->devicenum,MIXER_PARAM_MIC_BOOST,o->rxboostset,0); 03120 setamixer(o->devicenum,MIXER_PARAM_MIC_CAPTURE_SW,1,0); 03121 }
static int mult_calc | ( | int | value | ) | [static] |
Definition at line 3140 of file chan_usbradio.c.
Referenced by mult_set().
03141 { 03142 const int multx=M_Q8; 03143 int pot,mult; 03144 03145 pot=((int)(value/4)*4)+2; 03146 mult = multx-( ( multx * (3-(value%4)) ) / (pot+2) ); 03147 return(mult); 03148 }
static void mult_set | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 3125 of file chan_usbradio.c.
References mult_calc(), chan_usbradio_pvt::pmrChan, chan_usbradio_pvt::txmixaset, and chan_usbradio_pvt::txmixbset.
Referenced by radio_tune(), set_txctcss_level(), and store_config().
03126 { 03127 03128 if(o->pmrChan->spsTxOutA) { 03129 o->pmrChan->spsTxOutA->outputGain = 03130 mult_calc((o->txmixaset * 152) / 1000); 03131 } 03132 if(o->pmrChan->spsTxOutB){ 03133 o->pmrChan->spsTxOutB->outputGain = 03134 mult_calc((o->txmixbset * 152) / 1000); 03135 } 03136 }
static void pmrdump | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 3229 of file chan_usbradio.c.
References chan_usbradio_pvt::b, chan_usbradio_pvt::devicenum, chan_usbradio_pvt::devstr, chan_usbradio_pvt::micmax, chan_usbradio_pvt::numrxctcssfreqs, pd, pf, chan_usbradio_pvt::pmrChan, ps, chan_usbradio_pvt::rxboostset, chan_usbradio_pvt::rxcdtype, chan_usbradio_pvt::rxctcss, chan_usbradio_pvt::rxctcssadj, chan_usbradio_pvt::rxdemod, chan_usbradio_pvt::rxmixerset, chan_usbradio_pvt::rxpolarity, chan_usbradio_pvt::rxsdtype, chan_usbradio_pvt::rxsquelchadj, chan_usbradio_pvt::rxvoiceadj, chan_usbradio_pvt::spkrmax, chan_usbradio_pvt::txctcss, chan_usbradio_pvt::txctcssdefault, chan_usbradio_pvt::txctcssfreq, chan_usbradio_pvt::txmixa, chan_usbradio_pvt::txmixaset, chan_usbradio_pvt::txmixb, chan_usbradio_pvt::txmixbset, chan_usbradio_pvt::txpolarity, chan_usbradio_pvt::txprelim, and chan_usbradio_pvt::txtoctype.
Referenced by radio_tune().
03230 { 03231 t_pmr_chan *p; 03232 int i; 03233 03234 p=o->pmrChan; 03235 03236 printf("\nodump()\n"); 03237 03238 pd(o->devicenum); 03239 ps(o->devstr); 03240 03241 pd(o->micmax); 03242 pd(o->spkrmax); 03243 03244 pd(o->rxdemod); 03245 pd(o->rxcdtype); 03246 pd(o->rxsdtype); 03247 pd(o->txtoctype); 03248 03249 pd(o->rxmixerset); 03250 pd(o->rxboostset); 03251 03252 pf(o->rxvoiceadj); 03253 pf(o->rxctcssadj); 03254 pd(o->rxsquelchadj); 03255 03256 ps(o->txctcssdefault); 03257 ps(o->txctcssfreq); 03258 03259 pd(o->numrxctcssfreqs); 03260 if(o->numrxctcssfreqs>0) 03261 { 03262 for(i=0;i<o->numrxctcssfreqs;i++) 03263 { 03264 printf(" %i = %s %s\n",i,o->rxctcss[i],o->txctcss[i]); 03265 } 03266 } 03267 03268 pd(o->b.rxpolarity); 03269 pd(o->b.txpolarity); 03270 03271 pd(o->txprelim); 03272 pd(o->txmixa); 03273 pd(o->txmixb); 03274 03275 pd(o->txmixaset); 03276 pd(o->txmixbset); 03277 03278 printf("\npmrdump()\n"); 03279 03280 pd(p->devicenum); 03281 03282 printf("prxSquelchAdjust=%i\n",*(o->pmrChan->prxSquelchAdjust)); 03283 03284 pd(p->rxCarrierPoint); 03285 pd(p->rxCarrierHyst); 03286 03287 pd(*p->prxVoiceAdjust); 03288 pd(*p->prxCtcssAdjust); 03289 03290 pd(p->rxfreq); 03291 pd(p->txfreq); 03292 03293 pd(p->rxCtcss->relax); 03294 //pf(p->rxCtcssFreq); 03295 pd(p->numrxcodes); 03296 if(o->pmrChan->numrxcodes>0) 03297 { 03298 for(i=0;i<o->pmrChan->numrxcodes;i++) 03299 { 03300 printf(" %i = %s\n",i,o->pmrChan->pRxCode[i]); 03301 } 03302 } 03303 03304 pd(p->txTocType); 03305 ps(p->pTxCodeDefault); 03306 pd(p->txcodedefaultsmode); 03307 pd(p->numtxcodes); 03308 if(o->pmrChan->numtxcodes>0) 03309 { 03310 for(i=0;i<o->pmrChan->numtxcodes;i++) 03311 { 03312 printf(" %i = %s\n",i,o->pmrChan->pTxCode[i]); 03313 } 03314 } 03315 03316 pd(p->b.rxpolarity); 03317 pd(p->b.txpolarity); 03318 pd(p->b.dcsrxpolarity); 03319 pd(p->b.dcstxpolarity); 03320 pd(p->b.lsdrxpolarity); 03321 pd(p->b.lsdtxpolarity); 03322 03323 pd(p->txMixA); 03324 pd(p->txMixB); 03325 03326 pd(p->rxDeEmpEnable); 03327 pd(p->rxCenterSlicerEnable); 03328 pd(p->rxCtcssDecodeEnable); 03329 pd(p->rxDcsDecodeEnable); 03330 pd(p->b.ctcssRxEnable); 03331 pd(p->b.dcsRxEnable); 03332 pd(p->b.lmrRxEnable); 03333 pd(p->b.dstRxEnable); 03334 pd(p->smode); 03335 03336 pd(p->txHpfEnable); 03337 pd(p->txLimiterEnable); 03338 pd(p->txPreEmpEnable); 03339 pd(p->txLpfEnable); 03340 03341 if(p->spsTxOutA)pd(p->spsTxOutA->outputGain); 03342 if(p->spsTxOutB)pd(p->spsTxOutB->outputGain); 03343 pd(p->txPttIn); 03344 pd(p->txPttOut); 03345 03346 pd(p->tracetype); 03347 03348 return; 03349 }
static void put_eeprom | ( | struct usb_dev_handle * | handle, | |
unsigned short * | buf | |||
) | [static] |
Definition at line 867 of file chan_usbradio.c.
References EEPROM_CS_ADDR, EEPROM_MAGIC, EEPROM_MAGIC_ADDR, EEPROM_START_ADDR, and write_eeprom().
Referenced by hidthread().
00868 { 00869 int i; 00870 unsigned short cs; 00871 00872 cs = 0xffff; 00873 buf[EEPROM_MAGIC_ADDR] = EEPROM_MAGIC; 00874 for(i = EEPROM_START_ADDR; i < EEPROM_CS_ADDR; i++) 00875 { 00876 write_eeprom(handle,i,buf[i]); 00877 cs += buf[i]; 00878 } 00879 buf[EEPROM_CS_ADDR] = (65535 - cs) + 1; 00880 write_eeprom(handle,i,buf[EEPROM_CS_ADDR]); 00881 }
static int radio_active | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 2569 of file chan_usbradio.c.
References ast_cli(), find_desc(), chan_usbradio_pvt::name, chan_usbradio_pvt::next, chan_usbradio_pvt::pmrChan, RESULT_SHOWUSAGE, RESULT_SUCCESS, usbradio_active, and usbradio_default.
Referenced by handle_radio_active().
02570 { 02571 if (argc == 2) 02572 ast_cli(fd, "active (command) USB Radio device is [%s]\n", usbradio_active); 02573 else if (argc != 3) 02574 return RESULT_SHOWUSAGE; 02575 else { 02576 struct chan_usbradio_pvt *o; 02577 if (strcmp(argv[2], "show") == 0) { 02578 for (o = usbradio_default.next; o; o = o->next) 02579 ast_cli(fd, "device [%s] exists\n", o->name); 02580 return RESULT_SUCCESS; 02581 } 02582 o = find_desc(argv[2]); 02583 if (o == NULL) 02584 ast_cli(fd, "No device [%s] exists\n", argv[2]); 02585 else 02586 { 02587 struct chan_usbradio_pvt *ao; 02588 for (ao = usbradio_default.next; ao && ao->name ; ao = ao->next)ao->pmrChan->b.radioactive=0; 02589 usbradio_active = o->name; 02590 o->pmrChan->b.radioactive=1; 02591 } 02592 } 02593 return RESULT_SUCCESS; 02594 }
static int radio_set_debug | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 2551 of file chan_usbradio.c.
References ast_cli(), chan_usbradio_pvt::debuglevel, find_desc(), RESULT_SUCCESS, and usbradio_active.
Referenced by handle_radio_debug().
02552 { 02553 struct chan_usbradio_pvt *o = find_desc(usbradio_active); 02554 02555 o->debuglevel=1; 02556 ast_cli(fd,"usbradio debug on.\n"); 02557 return RESULT_SUCCESS; 02558 }
static int radio_set_debug_off | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 2560 of file chan_usbradio.c.
References ast_cli(), chan_usbradio_pvt::debuglevel, find_desc(), RESULT_SUCCESS, and usbradio_active.
Referenced by handle_radio_debug_off().
02561 { 02562 struct chan_usbradio_pvt *o = find_desc(usbradio_active); 02563 02564 o->debuglevel=0; 02565 ast_cli(fd,"usbradio debug off.\n"); 02566 return RESULT_SUCCESS; 02567 }
static int radio_set_xpmr_debug | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 2598 of file chan_usbradio.c.
References ast_cli(), find_desc(), chan_usbradio_pvt::pmrChan, RESULT_SUCCESS, and usbradio_active.
Referenced by handle_set_xdebug().
02599 { 02600 struct chan_usbradio_pvt *o = find_desc(usbradio_active); 02601 02602 if (argc == 4) 02603 { 02604 int i; 02605 i = atoi(argv[3]); 02606 if ((i >= 0) && (i <= 100)) 02607 { 02608 o->pmrChan->tracelevel=i; 02609 } 02610 } 02611 // add ability to set it for a number of frames after which it reverts 02612 ast_cli(fd,"usbradio xdebug on tracelevel %i\n",o->pmrChan->tracelevel); 02613 02614 return RESULT_SUCCESS; 02615 }
static int radio_tune | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 2279 of file chan_usbradio.c.
References ast_cli(), ast_log(), ast_mutex_lock, ast_mutex_unlock, chan_usbradio_pvt::b, chan_usbradio_pvt::devstr, chan_usbradio_pvt::eepromctl, chan_usbradio_pvt::eepromlock, find_desc(), frxcapraw, frxcaptrace, frxoutraw, ftxcapraw, ftxcaptrace, ftxoutraw, LOG_ERROR, LOG_WARNING, mixer_write(), mult_set(), chan_usbradio_pvt::name, chan_usbradio_pvt::pmrChan, pmrdump(), RESULT_SHOWUSAGE, RESULT_SUCCESS, RX_CAP_RAW_FILE, RX_CAP_TRACE_FILE, chan_usbradio_pvt::rxcap2, chan_usbradio_pvt::rxcapraw, chan_usbradio_pvt::rxsquelchadj, set_txctcss_level(), tune_rxctcss(), tune_rxinput(), tune_rxvoice(), tune_txoutput(), tune_write(), TX_CAP_RAW_FILE, TX_CAP_TRACE_FILE, TX_OUT_AUX, TX_OUT_COMPOSITE, TX_OUT_LSD, TX_OUT_VOICE, chan_usbradio_pvt::txcap2, chan_usbradio_pvt::txcapraw, chan_usbradio_pvt::txctcssadj, chan_usbradio_pvt::txmixa, chan_usbradio_pvt::txmixaset, chan_usbradio_pvt::txmixb, chan_usbradio_pvt::txmixbset, chan_usbradio_pvt::txtestkey, and usbradio_active.
Referenced by handle_radio_tune().
02280 { 02281 struct chan_usbradio_pvt *o = find_desc(usbradio_active); 02282 int i=0; 02283 02284 if ((argc < 2) || (argc > 4)) 02285 return RESULT_SHOWUSAGE; 02286 02287 if (argc == 2) /* just show stuff */ 02288 { 02289 ast_cli(fd,"Active radio interface is [%s]\n",usbradio_active); 02290 ast_cli(fd,"Output A is currently set to "); 02291 if(o->txmixa==TX_OUT_COMPOSITE)ast_cli(fd,"composite.\n"); 02292 else if (o->txmixa==TX_OUT_VOICE)ast_cli(fd,"voice.\n"); 02293 else if (o->txmixa==TX_OUT_LSD)ast_cli(fd,"tone.\n"); 02294 else if (o->txmixa==TX_OUT_AUX)ast_cli(fd,"auxvoice.\n"); 02295 else ast_cli(fd,"off.\n"); 02296 02297 ast_cli(fd,"Output B is currently set to "); 02298 if(o->txmixb==TX_OUT_COMPOSITE)ast_cli(fd,"composite.\n"); 02299 else if (o->txmixb==TX_OUT_VOICE)ast_cli(fd,"voice.\n"); 02300 else if (o->txmixb==TX_OUT_LSD)ast_cli(fd,"tone.\n"); 02301 else if (o->txmixb==TX_OUT_AUX)ast_cli(fd,"auxvoice.\n"); 02302 else ast_cli(fd,"off.\n"); 02303 02304 ast_cli(fd,"Tx Voice Level currently set to %d\n",o->txmixaset); 02305 ast_cli(fd,"Tx Tone Level currently set to %d\n",o->txctcssadj); 02306 ast_cli(fd,"Rx Squelch currently set to %d\n",o->rxsquelchadj); 02307 ast_cli(fd,"Device String is %s\n",o->devstr); 02308 return RESULT_SHOWUSAGE; 02309 } 02310 02311 o->pmrChan->b.tuning=1; 02312 02313 if (!strcasecmp(argv[2],"rxnoise")) tune_rxinput(fd,o); 02314 else if (!strcasecmp(argv[2],"rxvoice")) tune_rxvoice(fd,o); 02315 else if (!strcasecmp(argv[2],"rxtone")) tune_rxctcss(fd,o); 02316 else if (!strcasecmp(argv[2],"rxsquelch")) 02317 { 02318 if (argc == 3) 02319 { 02320 ast_cli(fd,"Current Signal Strength is %d\n",((32767-o->pmrChan->rxRssi)*1000/32767)); 02321 ast_cli(fd,"Current Squelch setting is %d\n",o->rxsquelchadj); 02322 //ast_cli(fd,"Current Raw RSSI is %d\n",o->pmrChan->rxRssi); 02323 //ast_cli(fd,"Current (real) Squelch setting is %d\n",*(o->pmrChan->prxSquelchAdjust)); 02324 } else { 02325 i = atoi(argv[3]); 02326 if ((i < 0) || (i > 999)) return RESULT_SHOWUSAGE; 02327 ast_cli(fd,"Changed Squelch setting to %d\n",i); 02328 o->rxsquelchadj = i; 02329 *(o->pmrChan->prxSquelchAdjust)= ((999 - i) * 32767) / 1000; 02330 } 02331 } 02332 else if (!strcasecmp(argv[2],"txvoice")) { 02333 i = 0; 02334 02335 if( (o->txmixa!=TX_OUT_VOICE) && (o->txmixb!=TX_OUT_VOICE) && 02336 (o->txmixa!=TX_OUT_COMPOSITE) && (o->txmixb!=TX_OUT_COMPOSITE) 02337 ) 02338 { 02339 ast_log(LOG_ERROR,"No txvoice output configured.\n"); 02340 } 02341 else if (argc == 3) 02342 { 02343 if((o->txmixa==TX_OUT_VOICE)||(o->txmixa==TX_OUT_COMPOSITE)) 02344 ast_cli(fd,"Current txvoice setting on Channel A is %d\n",o->txmixaset); 02345 else 02346 ast_cli(fd,"Current txvoice setting on Channel B is %d\n",o->txmixbset); 02347 } 02348 else 02349 { 02350 i = atoi(argv[3]); 02351 if ((i < 0) || (i > 999)) return RESULT_SHOWUSAGE; 02352 02353 if((o->txmixa==TX_OUT_VOICE)||(o->txmixa==TX_OUT_COMPOSITE)) 02354 { 02355 o->txmixaset=i; 02356 ast_cli(fd,"Changed txvoice setting on Channel A to %d\n",o->txmixaset); 02357 } 02358 else 02359 { 02360 o->txmixbset=i; 02361 ast_cli(fd,"Changed txvoice setting on Channel B to %d\n",o->txmixbset); 02362 } 02363 mixer_write(o); 02364 mult_set(o); 02365 ast_cli(fd,"Changed Tx Voice Output setting to %d\n",i); 02366 } 02367 o->pmrChan->b.txCtcssInhibit=1; 02368 tune_txoutput(o,i,fd); 02369 o->pmrChan->b.txCtcssInhibit=0; 02370 } 02371 else if (!strcasecmp(argv[2],"txall")) { 02372 i = 0; 02373 02374 if( (o->txmixa!=TX_OUT_VOICE) && (o->txmixb!=TX_OUT_VOICE) && 02375 (o->txmixa!=TX_OUT_COMPOSITE) && (o->txmixb!=TX_OUT_COMPOSITE) 02376 ) 02377 { 02378 ast_log(LOG_ERROR,"No txvoice output configured.\n"); 02379 } 02380 else if (argc == 3) 02381 { 02382 if((o->txmixa==TX_OUT_VOICE)||(o->txmixa==TX_OUT_COMPOSITE)) 02383 ast_cli(fd,"Current txvoice setting on Channel A is %d\n",o->txmixaset); 02384 else 02385 ast_cli(fd,"Current txvoice setting on Channel B is %d\n",o->txmixbset); 02386 } 02387 else 02388 { 02389 i = atoi(argv[3]); 02390 if ((i < 0) || (i > 999)) return RESULT_SHOWUSAGE; 02391 02392 if((o->txmixa==TX_OUT_VOICE)||(o->txmixa==TX_OUT_COMPOSITE)) 02393 { 02394 o->txmixaset=i; 02395 ast_cli(fd,"Changed txvoice setting on Channel A to %d\n",o->txmixaset); 02396 } 02397 else 02398 { 02399 o->txmixbset=i; 02400 ast_cli(fd,"Changed txvoice setting on Channel B to %d\n",o->txmixbset); 02401 } 02402 mixer_write(o); 02403 mult_set(o); 02404 ast_cli(fd,"Changed Tx Voice Output setting to %d\n",i); 02405 } 02406 tune_txoutput(o,i,fd); 02407 } 02408 else if (!strcasecmp(argv[2],"auxvoice")) { 02409 i = 0; 02410 if( (o->txmixa!=TX_OUT_AUX) && (o->txmixb!=TX_OUT_AUX)) 02411 { 02412 ast_log(LOG_WARNING,"No auxvoice output configured.\n"); 02413 } 02414 else if (argc == 3) 02415 { 02416 if(o->txmixa==TX_OUT_AUX) 02417 ast_cli(fd,"Current auxvoice setting on Channel A is %d\n",o->txmixaset); 02418 else 02419 ast_cli(fd,"Current auxvoice setting on Channel B is %d\n",o->txmixbset); 02420 } 02421 else 02422 { 02423 i = atoi(argv[3]); 02424 if ((i < 0) || (i > 999)) return RESULT_SHOWUSAGE; 02425 if(o->txmixa==TX_OUT_AUX) 02426 { 02427 o->txmixbset=i; 02428 ast_cli(fd,"Changed auxvoice setting on Channel A to %d\n",o->txmixaset); 02429 } 02430 else 02431 { 02432 o->txmixbset=i; 02433 ast_cli(fd,"Changed auxvoice setting on Channel B to %d\n",o->txmixbset); 02434 } 02435 mixer_write(o); 02436 mult_set(o); 02437 } 02438 //tune_auxoutput(o,i); 02439 } 02440 else if (!strcasecmp(argv[2],"txtone")) 02441 { 02442 if (argc == 3) 02443 ast_cli(fd,"Current Tx CTCSS modulation setting = %d\n",o->txctcssadj); 02444 else 02445 { 02446 i = atoi(argv[3]); 02447 if ((i < 0) || (i > 999)) return RESULT_SHOWUSAGE; 02448 o->txctcssadj = i; 02449 set_txctcss_level(o); 02450 ast_cli(fd,"Changed Tx CTCSS modulation setting to %i\n",i); 02451 } 02452 o->txtestkey=1; 02453 usleep(5000000); 02454 o->txtestkey=0; 02455 } 02456 else if (!strcasecmp(argv[2],"dump")) pmrdump(o); 02457 else if (!strcasecmp(argv[2],"nocap")) 02458 { 02459 ast_cli(fd,"File capture (trace) was rx=%d tx=%d and now off.\n",o->b.rxcap2,o->b.txcap2); 02460 ast_cli(fd,"File capture (raw) was rx=%d tx=%d and now off.\n",o->b.rxcapraw,o->b.txcapraw); 02461 o->b.rxcapraw=o->b.txcapraw=o->b.rxcap2=o->b.txcap2=o->pmrChan->b.rxCapture=o->pmrChan->b.txCapture=0; 02462 if (frxcapraw) { fclose(frxcapraw); frxcapraw = NULL; } 02463 if (frxcaptrace) { fclose(frxcaptrace); frxcaptrace = NULL; } 02464 if (frxoutraw) { fclose(frxoutraw); frxoutraw = NULL; } 02465 if (ftxcapraw) { fclose(ftxcapraw); ftxcapraw = NULL; } 02466 if (ftxcaptrace) { fclose(ftxcaptrace); ftxcaptrace = NULL; } 02467 if (ftxoutraw) { fclose(ftxoutraw); ftxoutraw = NULL; } 02468 } 02469 else if (!strcasecmp(argv[2],"rxtracecap")) 02470 { 02471 if (!frxcaptrace) frxcaptrace= fopen(RX_CAP_TRACE_FILE,"w"); 02472 ast_cli(fd,"Trace rx on.\n"); 02473 o->b.rxcap2=o->pmrChan->b.rxCapture=1; 02474 } 02475 else if (!strcasecmp(argv[2],"txtracecap")) 02476 { 02477 if (!ftxcaptrace) ftxcaptrace= fopen(TX_CAP_TRACE_FILE,"w"); 02478 ast_cli(fd,"Trace tx on.\n"); 02479 o->b.txcap2=o->pmrChan->b.txCapture=1; 02480 } 02481 else if (!strcasecmp(argv[2],"rxcap")) 02482 { 02483 if (!frxcapraw) frxcapraw = fopen(RX_CAP_RAW_FILE,"w"); 02484 ast_cli(fd,"cap rx raw on.\n"); 02485 o->b.rxcapraw=1; 02486 } 02487 else if (!strcasecmp(argv[2],"txcap")) 02488 { 02489 if (!ftxcapraw) ftxcapraw = fopen(TX_CAP_RAW_FILE,"w"); 02490 ast_cli(fd,"cap tx raw on.\n"); 02491 o->b.txcapraw=1; 02492 } 02493 else if (!strcasecmp(argv[2],"save")) 02494 { 02495 tune_write(o); 02496 ast_cli(fd,"Saved radio tuning settings to usbradio_tune_%s.conf\n",o->name); 02497 } 02498 else if (!strcasecmp(argv[2],"load")) 02499 { 02500 ast_mutex_lock(&o->eepromlock); 02501 while(o->eepromctl) 02502 { 02503 ast_mutex_unlock(&o->eepromlock); 02504 usleep(10000); 02505 ast_mutex_lock(&o->eepromlock); 02506 } 02507 o->eepromctl = 1; /* request a load */ 02508 ast_mutex_unlock(&o->eepromlock); 02509 02510 ast_cli(fd,"Requesting loading of tuning settings from EEPROM for channel %s\n",o->name); 02511 } 02512 else 02513 { 02514 o->pmrChan->b.tuning=0; 02515 return RESULT_SHOWUSAGE; 02516 } 02517 o->pmrChan->b.tuning=0; 02518 return RESULT_SUCCESS; 02519 }
static unsigned short read_eeprom | ( | struct usb_dev_handle * | handle, | |
int | addr | |||
) | [static] |
Definition at line 826 of file chan_usbradio.c.
References hid_get_inputs(), and hid_set_outputs().
Referenced by get_eeprom().
00827 { 00828 unsigned char buf[4]; 00829 00830 buf[0] = 0x80; 00831 buf[1] = 0; 00832 buf[2] = 0; 00833 buf[3] = 0x80 | (addr & 0x3f); 00834 hid_set_outputs(handle,buf); 00835 memset(buf,0,sizeof(buf)); 00836 hid_get_inputs(handle,buf); 00837 return(buf[1] + (buf[2] << 8)); 00838 }
static char* res2cli | ( | int | r | ) | [static] |
Definition at line 3795 of file chan_usbradio.c.
References CLI_FAILURE, CLI_SHOWUSAGE, CLI_SUCCESS, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
03797 { 03798 switch (r) 03799 { 03800 case RESULT_SUCCESS: 03801 return(CLI_SUCCESS); 03802 case RESULT_SHOWUSAGE: 03803 return(CLI_SHOWUSAGE); 03804 default: 03805 return(CLI_FAILURE); 03806 } 03807 }
static void ring | ( | struct chan_usbradio_pvt * | o, | |
int | x | |||
) | [static] |
Definition at line 1676 of file chan_usbradio.c.
Referenced by store_tone_zone_ring_cadence(), usbradio_hangup(), and usbradio_indicate().
static int set_txctcss_level | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 2526 of file chan_usbradio.c.
References mixer_write(), mult_set(), chan_usbradio_pvt::pmrChan, TX_OUT_LSD, chan_usbradio_pvt::txctcssadj, chan_usbradio_pvt::txmixa, chan_usbradio_pvt::txmixaset, chan_usbradio_pvt::txmixb, and chan_usbradio_pvt::txmixbset.
Referenced by radio_tune(), and store_config().
02527 { 02528 if (o->txmixa == TX_OUT_LSD) 02529 { 02530 // o->txmixaset=(151*o->txctcssadj) / 1000; 02531 o->txmixaset=o->txctcssadj; 02532 mixer_write(o); 02533 mult_set(o); 02534 } 02535 else if (o->txmixb == TX_OUT_LSD) 02536 { 02537 // o->txmixbset=(151*o->txctcssadj) / 1000; 02538 o->txmixbset=o->txctcssadj; 02539 mixer_write(o); 02540 mult_set(o); 02541 } 02542 else 02543 { 02544 *o->pmrChan->ptxCtcssAdjust=(o->txctcssadj * M_Q8) / 1000; 02545 } 02546 return 0; 02547 }
static int setamixer | ( | int | devnum, | |
char * | param, | |||
int | v1, | |||
int | v2 | |||
) | [static] |
Definition at line 756 of file chan_usbradio.c.
Referenced by mixer_write(), and tune_rxinput().
00757 { 00758 int type; 00759 char str[100]; 00760 snd_hctl_t *hctl; 00761 snd_ctl_elem_id_t *id; 00762 snd_ctl_elem_value_t *control; 00763 snd_hctl_elem_t *elem; 00764 snd_ctl_elem_info_t *info; 00765 00766 sprintf(str,"hw:%d",devnum); 00767 if (snd_hctl_open(&hctl, str, 0)) return(-1); 00768 snd_hctl_load(hctl); 00769 snd_ctl_elem_id_alloca(&id); 00770 snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); 00771 snd_ctl_elem_id_set_name(id, param); 00772 elem = snd_hctl_find_elem(hctl, id); 00773 if (!elem) 00774 { 00775 snd_hctl_close(hctl); 00776 return(-1); 00777 } 00778 snd_ctl_elem_info_alloca(&info); 00779 snd_hctl_elem_info(elem,info); 00780 type = snd_ctl_elem_info_get_type(info); 00781 snd_ctl_elem_value_alloca(&control); 00782 snd_ctl_elem_value_set_id(control, id); 00783 switch(type) 00784 { 00785 case SND_CTL_ELEM_TYPE_INTEGER: 00786 snd_ctl_elem_value_set_integer(control, 0, v1); 00787 if (v2 > 0) snd_ctl_elem_value_set_integer(control, 1, v2); 00788 break; 00789 case SND_CTL_ELEM_TYPE_BOOLEAN: 00790 snd_ctl_elem_value_set_integer(control, 0, (v1 != 0)); 00791 break; 00792 } 00793 if (snd_hctl_elem_write(elem, control)) 00794 { 00795 snd_hctl_close(hctl); 00796 return(-1); 00797 } 00798 snd_hctl_close(hctl); 00799 return(0); 00800 }
static int setformat | ( | struct chan_usbradio_pvt * | o, | |
int | mode | |||
) | [static] |
Definition at line 1507 of file chan_usbradio.c.
References ast_log(), ast_tvnow(), ast_verbose, chan_usbradio_pvt::devicenum, chan_usbradio_pvt::duplex, errno, ast_channel::fds, chan_usbradio_pvt::frags, chan_usbradio_pvt::lastopen, LOG_WARNING, chan_usbradio_pvt::M_FULL, chan_usbradio_pvt::M_READ, chan_usbradio_pvt::M_UNSET, chan_usbradio_pvt::M_WRITE, O_CLOSE, option_verbose, chan_usbradio_pvt::owner, chan_usbradio_pvt::sounddev, VERBOSE_PREFIX_2, WARN_frag, WARN_speed, and chan_usbradio_pvt::warned.
01508 { 01509 int fmt, desired, res, fd; 01510 char device[100]; 01511 01512 if (o->sounddev >= 0) { 01513 ioctl(o->sounddev, SNDCTL_DSP_RESET, 0); 01514 close(o->sounddev); 01515 o->duplex = M_UNSET; 01516 o->sounddev = -1; 01517 } 01518 if (mode == O_CLOSE) /* we are done */ 01519 return 0; 01520 o->lastopen = ast_tvnow(); 01521 strcpy(device,"/dev/dsp"); 01522 if (o->devicenum) 01523 sprintf(device,"/dev/dsp%d",o->devicenum); 01524 fd = o->sounddev = open(device, mode | O_NONBLOCK); 01525 if (fd < 0) { 01526 ast_log(LOG_WARNING, "Unable to re-open DSP device %d: %s\n", o->devicenum, strerror(errno)); 01527 return -1; 01528 } 01529 if (o->owner) 01530 o->owner->fds[0] = fd; 01531 01532 #if __BYTE_ORDER == __LITTLE_ENDIAN 01533 fmt = AFMT_S16_LE; 01534 #else 01535 fmt = AFMT_S16_BE; 01536 #endif 01537 res = ioctl(fd, SNDCTL_DSP_SETFMT, &fmt); 01538 if (res < 0) { 01539 ast_log(LOG_WARNING, "Unable to set format to 16-bit signed\n"); 01540 return -1; 01541 } 01542 switch (mode) { 01543 case O_RDWR: 01544 res = ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0); 01545 /* Check to see if duplex set (FreeBSD Bug) */ 01546 res = ioctl(fd, SNDCTL_DSP_GETCAPS, &fmt); 01547 if (res == 0 && (fmt & DSP_CAP_DUPLEX)) { 01548 if (option_verbose > 1) 01549 ast_verbose(VERBOSE_PREFIX_2 "Console is full duplex\n"); 01550 o->duplex = M_FULL; 01551 }; 01552 break; 01553 case O_WRONLY: 01554 o->duplex = M_WRITE; 01555 break; 01556 case O_RDONLY: 01557 o->duplex = M_READ; 01558 break; 01559 } 01560 01561 fmt = 1; 01562 res = ioctl(fd, SNDCTL_DSP_STEREO, &fmt); 01563 if (res < 0) { 01564 ast_log(LOG_WARNING, "Failed to set audio device to mono\n"); 01565 return -1; 01566 } 01567 fmt = desired = 48000; /* 8000 Hz desired */ 01568 res = ioctl(fd, SNDCTL_DSP_SPEED, &fmt); 01569 01570 if (res < 0) { 01571 ast_log(LOG_WARNING, "Failed to set audio device to mono\n"); 01572 return -1; 01573 } 01574 if (fmt != desired) { 01575 if (!(o->warned & WARN_speed)) { 01576 ast_log(LOG_WARNING, 01577 "Requested %d Hz, got %d Hz -- sound may be choppy\n", 01578 desired, fmt); 01579 o->warned |= WARN_speed; 01580 } 01581 } 01582 /* 01583 * on Freebsd, SETFRAGMENT does not work very well on some cards. 01584 * Default to use 256 bytes, let the user override 01585 */ 01586 if (o->frags) { 01587 fmt = o->frags; 01588 res = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &fmt); 01589 if (res < 0) { 01590 if (!(o->warned & WARN_frag)) { 01591 ast_log(LOG_WARNING, 01592 "Unable to set fragment size -- sound may be choppy\n"); 01593 o->warned |= WARN_frag; 01594 } 01595 } 01596 } 01597 /* on some cards, we need SNDCTL_DSP_SETTRIGGER to start outputting */ 01598 res = PCM_ENABLE_INPUT | PCM_ENABLE_OUTPUT; 01599 res = ioctl(fd, SNDCTL_DSP_SETTRIGGER, &res); 01600 /* it may fail if we are in half duplex, never mind */ 01601 return 0; 01602 }
static int soundcard_writeframe | ( | struct chan_usbradio_pvt * | o, | |
short * | data | |||
) | [static] |
Definition at line 1344 of file chan_usbradio.c.
References ast_log(), FRAME_SIZE, LOG_WARNING, chan_usbradio_pvt::pmrChan, chan_usbradio_pvt::queuesize, setformat(), chan_usbradio_pvt::sounddev, usbradio_debug, used_blocks(), and chan_usbradio_pvt::w_errors.
01345 { 01346 int res; 01347 01348 if (o->sounddev < 0) 01349 setformat(o, O_RDWR); 01350 if (o->sounddev < 0) 01351 return 0; /* not fatal */ 01352 // maw maw sph !!! may or may not be a good thing 01353 // drop the frame if not transmitting, this keeps from gradually 01354 // filling the buffer when asterisk clock > usb sound clock 01355 if(!o->pmrChan->txPttIn && !o->pmrChan->txPttOut) 01356 { 01357 //return 0; 01358 } 01359 /* 01360 * Nothing complex to manage the audio device queue. 01361 * If the buffer is full just drop the extra, otherwise write. 01362 * XXX in some cases it might be useful to write anyways after 01363 * a number of failures, to restart the output chain. 01364 */ 01365 res = used_blocks(o); 01366 if (res > o->queuesize) { /* no room to write a block */ 01367 // ast_log(LOG_WARNING, "sound device write buffer overflow\n"); 01368 if (o->w_errors++ == 0 && (usbradio_debug & 0x4)) 01369 ast_log(LOG_WARNING, "write: used %d blocks (%d)\n", res, o->w_errors); 01370 return 0; 01371 } 01372 o->w_errors = 0; 01373 01374 return write(o->sounddev, ((void *) data), FRAME_SIZE * 2 * 12); 01375 }
static struct chan_usbradio_pvt* store_config | ( | struct ast_config * | cfg, | |
char * | ctg | |||
) | [static] |
Definition at line 3400 of file chan_usbradio.c.
References amixer_max(), chan_usbradio_pvt::area, ast_calloc, ast_config_destroy(), ast_config_load, ast_dsp_new(), ast_dsp_set_digitmode(), ast_dsp_set_features(), ast_jb_read_conf(), ast_log(), ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_pthread_create_background, ast_strdup, ast_tvnow(), ast_variable_browse(), chan_usbradio_pvt::autoanswer, chan_usbradio_pvt::autohangup, chan_usbradio_pvt::b, config1, CONFIG_STATUS_FILEINVALID, chan_usbradio_pvt::ctx, chan_usbradio_pvt::dcsrxpolarity, chan_usbradio_pvt::dcstxpolarity, chan_usbradio_pvt::debuglevel, chan_usbradio_pvt::devicenum, chan_usbradio_pvt::devstr, chan_usbradio_pvt::dsp, DSP_DIGITMODE_DTMF, DSP_DIGITMODE_MUTECONF, DSP_DIGITMODE_RELAXDTMF, DSP_FEATURE_DIGIT_DETECT, chan_usbradio_pvt::eepromctl, chan_usbradio_pvt::eepromlock, chan_usbradio_pvt::ext, find_desc_usb(), chan_usbradio_pvt::frags, free, global_jbconf, chan_usbradio_pvt::hdwtype, hidhdwconfig(), chan_usbradio_pvt::idleinterval, chan_usbradio_pvt::invertptt, chan_usbradio_pvt::language, chan_usbradio_pvt::lastopen, LOG_ERROR, LOG_NOTICE, LOG_WARNING, chan_usbradio_pvt::loopback, chan_usbradio_pvt::lsdrxpolarity, chan_usbradio_pvt::lsdtxpolarity, M_BOOL, M_END, M_F, M_START, M_STR, M_UINT, chan_usbradio_pvt::micmax, MIXER_PARAM_MIC_CAPTURE_VOL, MIXER_PARAM_SPKR_PLAYBACK_VOL, mixer_write(), chan_usbradio_pvt::mohinterpret, mult_set(), ast_variable::name, chan_usbradio_pvt::name, chan_usbradio_pvt::next, ast_variable::next, chan_usbradio_pvt::overridecontext, chan_usbradio_pvt::pmrChan, chan_usbradio_pvt::queuesize, chan_usbradio_pvt::radioactive, chan_usbradio_pvt::radioduplex, chan_usbradio_pvt::rptnum, chan_usbradio_pvt::rxboostset, chan_usbradio_pvt::rxcdtype, chan_usbradio_pvt::rxcpusaver, chan_usbradio_pvt::rxctcssadj, chan_usbradio_pvt::rxctcssfreqs, chan_usbradio_pvt::rxctcssrelax, chan_usbradio_pvt::rxdemod, chan_usbradio_pvt::rxfreq, chan_usbradio_pvt::rxmixerset, chan_usbradio_pvt::rxpolarity, chan_usbradio_pvt::rxsquelchadj, chan_usbradio_pvt::rxsqvoxadj, chan_usbradio_pvt::rxvoiceadj, set_txctcss_level(), chan_usbradio_pvt::spkrmax, store_callerid(), store_rxcdtype(), store_rxctcssadj(), store_rxdemod(), store_rxgain(), store_rxsdtype(), store_rxvoiceadj(), store_txmixa(), store_txmixb(), store_txtoctype(), chan_usbradio_pvt::tracelevel, chan_usbradio_pvt::tracetype, traceusb1, chan_usbradio_pvt::turnoffs, TX_OUT_COMPOSITE, TX_OUT_LSD, TX_OUT_VOICE, chan_usbradio_pvt::txcpusaver, chan_usbradio_pvt::txctcssadj, chan_usbradio_pvt::txctcssdefault, chan_usbradio_pvt::txctcssfreq, chan_usbradio_pvt::txctcssfreqs, chan_usbradio_pvt::txfreq, chan_usbradio_pvt::txmixa, chan_usbradio_pvt::txmixaset, chan_usbradio_pvt::txmixb, chan_usbradio_pvt::txmixbset, chan_usbradio_pvt::txpolarity, chan_usbradio_pvt::txprelim, chan_usbradio_pvt::txsettletime, chan_usbradio_pvt::txtoctype, chan_usbradio_pvt::ukey, usb_device_list, usb_get_usbdev(), usb_list_check(), usbradio_active, usbradio_debug, usbradio_default, ast_variable::value, chan_usbradio_pvt::wanteeprom, and xpmr_config().
03401 { 03402 struct ast_variable *v; 03403 struct chan_usbradio_pvt *o; 03404 struct ast_config *cfg1; 03405 int i; 03406 char fname[200]; 03407 #ifdef NEW_ASTERISK 03408 struct ast_flags zeroflag = {0}; 03409 #endif 03410 if (ctg == NULL) { 03411 traceusb1((" store_config() ctg == NULL\n")); 03412 o = &usbradio_default; 03413 ctg = "general"; 03414 } else { 03415 /* "general" is also the default thing */ 03416 if (strcmp(ctg, "general") == 0) { 03417 o = &usbradio_default; 03418 } else { 03419 // ast_log(LOG_NOTICE,"ast_calloc for chan_usbradio_pvt of %s\n",ctg); 03420 if (!(o = ast_calloc(1, sizeof(*o)))) 03421 return NULL; 03422 *o = usbradio_default; 03423 o->name = ast_strdup(ctg); 03424 if (!usbradio_active) 03425 usbradio_active = o->name; 03426 } 03427 } 03428 ast_mutex_init(&o->eepromlock); 03429 strcpy(o->mohinterpret, "default"); 03430 /* fill other fields from configuration */ 03431 for (v = ast_variable_browse(cfg, ctg); v; v = v->next) { 03432 M_START((char *)v->name, (char *)v->value); 03433 03434 /* handle jb conf */ 03435 if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) 03436 continue; 03437 03438 #if 0 03439 M_BOOL("autoanswer", o->autoanswer) 03440 M_BOOL("autohangup", o->autohangup) 03441 M_BOOL("overridecontext", o->overridecontext) 03442 M_STR("context", o->ctx) 03443 M_STR("language", o->language) 03444 M_STR("mohinterpret", o->mohinterpret) 03445 M_STR("extension", o->ext) 03446 M_F("callerid", store_callerid(o, v->value)) 03447 #endif 03448 M_UINT("frags", o->frags) 03449 M_UINT("queuesize",o->queuesize) 03450 #if 0 03451 M_UINT("devicenum",o->devicenum) 03452 #endif 03453 M_UINT("debug", usbradio_debug) 03454 M_BOOL("rxcpusaver",o->rxcpusaver) 03455 M_BOOL("txcpusaver",o->txcpusaver) 03456 M_BOOL("invertptt",o->invertptt) 03457 M_F("rxdemod",store_rxdemod(o,(char *)v->value)) 03458 M_BOOL("txprelim",o->txprelim); 03459 M_F("txmixa",store_txmixa(o,(char *)v->value)) 03460 M_F("txmixb",store_txmixb(o,(char *)v->value)) 03461 M_F("carrierfrom",store_rxcdtype(o,(char *)v->value)) 03462 M_F("rxsdtype",store_rxsdtype(o,(char *)v->value)) 03463 M_UINT("rxsqvox",o->rxsqvoxadj) 03464 M_STR("txctcssdefault",o->txctcssdefault) 03465 M_STR("rxctcssfreqs",o->rxctcssfreqs) 03466 M_STR("txctcssfreqs",o->txctcssfreqs) 03467 M_UINT("rxfreq",o->rxfreq) 03468 M_UINT("txfreq",o->txfreq) 03469 M_F("rxgain",store_rxgain(o,(char *)v->value)) 03470 M_BOOL("rxboost",o->rxboostset) 03471 M_UINT("rxctcssrelax",o->rxctcssrelax) 03472 M_F("txtoctype",store_txtoctype(o,(char *)v->value)) 03473 M_UINT("hdwtype",o->hdwtype) 03474 M_UINT("eeprom",o->wanteeprom) 03475 M_UINT("duplex",o->radioduplex) 03476 M_UINT("txsettletime",o->txsettletime) 03477 M_BOOL("rxpolarity",o->b.rxpolarity) 03478 M_BOOL("txpolarity",o->b.txpolarity) 03479 M_BOOL("dcsrxpolarity",o->b.dcsrxpolarity) 03480 M_BOOL("dcstxpolarity",o->b.dcstxpolarity) 03481 M_BOOL("lsdrxpolarity",o->b.lsdrxpolarity) 03482 M_BOOL("lsdtxpolarity",o->b.lsdtxpolarity) 03483 M_BOOL("loopback",o->b.loopback) 03484 M_BOOL("radioactive",o->b.radioactive) 03485 M_UINT("rptnum",o->rptnum) 03486 M_UINT("idleinterval",o->idleinterval) 03487 M_UINT("turnoffs",o->turnoffs) 03488 M_UINT("tracetype",o->tracetype) 03489 M_UINT("tracelevel",o->tracelevel) 03490 M_UINT("area",o->area) 03491 M_STR("ukey",o->ukey) 03492 M_END(; 03493 ); 03494 } 03495 03496 o->debuglevel=0; 03497 03498 if (o == &usbradio_default) /* we are done with the default */ 03499 return NULL; 03500 03501 snprintf(fname,sizeof(fname) - 1,config1,o->name); 03502 #ifdef NEW_ASTERISK 03503 cfg1 = ast_config_load(fname,zeroflag); 03504 #else 03505 cfg1 = ast_config_load(fname); 03506 #endif 03507 o->rxmixerset = 500; 03508 o->txmixaset = 500; 03509 o->txmixbset = 500; 03510 o->rxvoiceadj = 0.5; 03511 o->rxctcssadj = 0.5; 03512 o->txctcssadj = 200; 03513 o->rxsquelchadj = 500; 03514 o->devstr[0] = 0; 03515 if (cfg1 && cfg1 != CONFIG_STATUS_FILEINVALID) { 03516 for (v = ast_variable_browse(cfg1, o->name); v; v = v->next) { 03517 03518 M_START((char *)v->name, (char *)v->value); 03519 M_UINT("rxmixerset", o->rxmixerset) 03520 M_UINT("txmixaset", o->txmixaset) 03521 M_UINT("txmixbset", o->txmixbset) 03522 M_F("rxvoiceadj",store_rxvoiceadj(o,(char *)v->value)) 03523 M_F("rxctcssadj",store_rxctcssadj(o,(char *)v->value)) 03524 M_UINT("txctcssadj",o->txctcssadj); 03525 M_UINT("rxsquelchadj", o->rxsquelchadj) 03526 M_STR("devstr", o->devstr) 03527 M_END(; 03528 ); 03529 } 03530 ast_config_destroy(cfg1); 03531 } else ast_log(LOG_WARNING,"File %s not found, using default parameters.\n",fname); 03532 03533 if(o->wanteeprom) 03534 { 03535 ast_mutex_lock(&o->eepromlock); 03536 while(o->eepromctl) 03537 { 03538 ast_mutex_unlock(&o->eepromlock); 03539 usleep(10000); 03540 ast_mutex_lock(&o->eepromlock); 03541 } 03542 o->eepromctl = 1; /* request a load */ 03543 ast_mutex_unlock(&o->eepromlock); 03544 } 03545 /* if our specified one exists in the list */ 03546 if ((!usb_list_check(o->devstr)) || find_desc_usb(o->devstr)) 03547 { 03548 char *s; 03549 03550 for(s = usb_device_list; *s; s += strlen(s) + 1) 03551 { 03552 if (!find_desc_usb(s)) break; 03553 } 03554 if (!*s) 03555 { 03556 ast_log(LOG_WARNING,"Unable to assign USB device for channel %s\n",o->name); 03557 goto error; 03558 } 03559 ast_log(LOG_NOTICE,"Assigned USB device %s to usbradio channel %s\n",s,o->name); 03560 strcpy(o->devstr,s); 03561 } 03562 03563 i = usb_get_usbdev(o->devstr); 03564 if (i < 0) 03565 { 03566 ast_log(LOG_ERROR,"Not able to find alsa USB device\n"); 03567 goto error; 03568 } 03569 o->devicenum = i; 03570 03571 o->micmax = amixer_max(o->devicenum,MIXER_PARAM_MIC_CAPTURE_VOL); 03572 o->spkrmax = amixer_max(o->devicenum,MIXER_PARAM_SPKR_PLAYBACK_VOL); 03573 o->lastopen = ast_tvnow(); /* don't leave it 0 or tvdiff may wrap */ 03574 o->dsp = ast_dsp_new(); 03575 if (o->dsp) 03576 { 03577 #ifdef NEW_ASTERISK 03578 ast_dsp_set_features(o->dsp,DSP_FEATURE_DIGIT_DETECT); 03579 ast_dsp_set_digitmode(o->dsp,DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_RELAXDTMF); 03580 #else 03581 ast_dsp_set_features(o->dsp,DSP_FEATURE_DTMF_DETECT); 03582 ast_dsp_digitmode(o->dsp,DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_RELAXDTMF); 03583 #endif 03584 } 03585 03586 if(o->pmrChan==NULL) 03587 { 03588 t_pmr_chan tChan; 03589 03590 // ast_log(LOG_NOTICE,"createPmrChannel() %s\n",o->name); 03591 memset(&tChan,0,sizeof(t_pmr_chan)); 03592 03593 tChan.pTxCodeDefault = o->txctcssdefault; 03594 tChan.pRxCodeSrc = o->rxctcssfreqs; 03595 tChan.pTxCodeSrc = o->txctcssfreqs; 03596 03597 tChan.rxDemod=o->rxdemod; 03598 tChan.rxCdType=o->rxcdtype; 03599 tChan.rxSqVoxAdj=o->rxsqvoxadj; 03600 03601 if (o->txprelim) 03602 tChan.txMod = 2; 03603 03604 tChan.txMixA = o->txmixa; 03605 tChan.txMixB = o->txmixb; 03606 03607 tChan.rxCpuSaver=o->rxcpusaver; 03608 tChan.txCpuSaver=o->txcpusaver; 03609 03610 tChan.b.rxpolarity=o->b.rxpolarity; 03611 tChan.b.txpolarity=o->b.txpolarity; 03612 03613 tChan.b.dcsrxpolarity=o->b.dcsrxpolarity; 03614 tChan.b.dcstxpolarity=o->b.dcstxpolarity; 03615 03616 tChan.b.lsdrxpolarity=o->b.lsdrxpolarity; 03617 tChan.b.lsdtxpolarity=o->b.lsdtxpolarity; 03618 03619 tChan.tracetype=o->tracetype; 03620 tChan.tracelevel=o->tracelevel; 03621 tChan.rptnum=o->rptnum; 03622 tChan.idleinterval=o->idleinterval; 03623 tChan.turnoffs=o->turnoffs; 03624 tChan.area=o->area; 03625 tChan.ukey=o->ukey; 03626 tChan.name=o->name; 03627 03628 o->pmrChan=createPmrChannel(&tChan,FRAME_SIZE); 03629 03630 o->pmrChan->radioDuplex=o->radioduplex; 03631 o->pmrChan->b.loopback=0; 03632 o->pmrChan->txsettletime=o->txsettletime; 03633 o->pmrChan->rxCpuSaver=o->rxcpusaver; 03634 o->pmrChan->txCpuSaver=o->txcpusaver; 03635 03636 *(o->pmrChan->prxSquelchAdjust) = 03637 ((999 - o->rxsquelchadj) * 32767) / 1000; 03638 03639 *(o->pmrChan->prxVoiceAdjust)=o->rxvoiceadj*M_Q8; 03640 *(o->pmrChan->prxCtcssAdjust)=o->rxctcssadj*M_Q8; 03641 o->pmrChan->rxCtcss->relax=o->rxctcssrelax; 03642 o->pmrChan->txTocType = o->txtoctype; 03643 03644 if ( (o->txmixa == TX_OUT_LSD) || 03645 (o->txmixa == TX_OUT_COMPOSITE) || 03646 (o->txmixb == TX_OUT_LSD) || 03647 (o->txmixb == TX_OUT_COMPOSITE)) 03648 { 03649 set_txctcss_level(o); 03650 } 03651 03652 if( (o->txmixa!=TX_OUT_VOICE) && (o->txmixb!=TX_OUT_VOICE) && 03653 (o->txmixa!=TX_OUT_COMPOSITE) && (o->txmixb!=TX_OUT_COMPOSITE) 03654 ) 03655 { 03656 ast_log(LOG_ERROR,"No txvoice output configured.\n"); 03657 } 03658 03659 if( o->txctcssfreq[0] && 03660 o->txmixa!=TX_OUT_LSD && o->txmixa!=TX_OUT_COMPOSITE && 03661 o->txmixb!=TX_OUT_LSD && o->txmixb!=TX_OUT_COMPOSITE 03662 ) 03663 { 03664 ast_log(LOG_ERROR,"No txtone output configured.\n"); 03665 } 03666 03667 if(o->b.radioactive) 03668 { 03669 // 20080328 sphenke asdf maw !!! 03670 // this diagnostic option was working but now appears broken 03671 // it's not required for operation so I'll fix it later. 03672 //struct chan_usbradio_pvt *ao; 03673 //for (ao = usbradio_default.next; ao && ao->name ; ao = ao->next)ao->pmrChan->b.radioactive=0; 03674 usbradio_active = o->name; 03675 // o->pmrChan->b.radioactive=1; 03676 //o->b.radioactive=0; 03677 //o->pmrChan->b.radioactive=0; 03678 ast_log(LOG_NOTICE,"radio active set to [%s]\n",o->name); 03679 } 03680 } 03681 03682 xpmr_config(o); 03683 03684 TRACEO(1,("store_config() 120\n")); 03685 mixer_write(o); 03686 TRACEO(1,("store_config() 130\n")); 03687 mult_set(o); 03688 TRACEO(1,("store_config() 140\n")); 03689 hidhdwconfig(o); 03690 03691 TRACEO(1,("store_config() 200\n")); 03692 03693 #ifndef NEW_ASTERISK 03694 if (pipe(o->sndcmd) != 0) { 03695 ast_log(LOG_ERROR, "Unable to create pipe\n"); 03696 goto error; 03697 } 03698 03699 ast_pthread_create_background(&o->sthread, NULL, sound_thread, o); 03700 #endif 03701 03702 /* link into list of devices */ 03703 if (o != &usbradio_default) { 03704 o->next = usbradio_default.next; 03705 usbradio_default.next = o; 03706 } 03707 TRACEO(1,("store_config() complete\n")); 03708 return o; 03709 03710 error: 03711 if (o != &usbradio_default) 03712 free(o); 03713 return NULL; 03714 }
static void store_rxcdtype | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2759 of file chan_usbradio.c.
References ast_log(), CD_HID, CD_HID_INVERT, CD_IGNORE, CD_XPMR_NOISE, CD_XPMR_VOX, LOG_WARNING, and chan_usbradio_pvt::rxcdtype.
Referenced by store_config().
02760 { 02761 if (!strcasecmp(s,"no")){ 02762 o->rxcdtype = CD_IGNORE; 02763 } 02764 else if (!strcasecmp(s,"usb")){ 02765 o->rxcdtype = CD_HID; 02766 } 02767 else if (!strcasecmp(s,"dsp")){ 02768 o->rxcdtype = CD_XPMR_NOISE; 02769 } 02770 else if (!strcasecmp(s,"vox")){ 02771 o->rxcdtype = CD_XPMR_VOX; 02772 } 02773 else if (!strcasecmp(s,"usbinvert")){ 02774 o->rxcdtype = CD_HID_INVERT; 02775 } 02776 else { 02777 ast_log(LOG_WARNING,"Unrecognized rxcdtype parameter: %s\n",s); 02778 } 02779 02780 //ast_log(LOG_WARNING, "set rxcdtype = %s\n", s); 02781 }
static void store_rxctcssadj | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2824 of file chan_usbradio.c.
References f, and chan_usbradio_pvt::rxctcssadj.
Referenced by store_config().
02825 { 02826 float f; 02827 sscanf(s, "%30f", &f); 02828 o->rxctcssadj = f; 02829 //ast_log(LOG_WARNING, "set rxctcssadj = %f\n", f); 02830 }
static void store_rxdemod | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2691 of file chan_usbradio.c.
References ast_log(), LOG_WARNING, RX_AUDIO_FLAT, RX_AUDIO_NONE, RX_AUDIO_SPEAKER, and chan_usbradio_pvt::rxdemod.
Referenced by store_config().
02692 { 02693 if (!strcasecmp(s,"no")){ 02694 o->rxdemod = RX_AUDIO_NONE; 02695 } 02696 else if (!strcasecmp(s,"speaker")){ 02697 o->rxdemod = RX_AUDIO_SPEAKER; 02698 } 02699 else if (!strcasecmp(s,"flat")){ 02700 o->rxdemod = RX_AUDIO_FLAT; 02701 } 02702 else { 02703 ast_log(LOG_WARNING,"Unrecognized rxdemod parameter: %s\n",s); 02704 } 02705 02706 //ast_log(LOG_WARNING, "set rxdemod = %s\n", s); 02707 }
static void store_rxgain | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2806 of file chan_usbradio.c.
References f, and chan_usbradio_pvt::rxgain.
Referenced by store_config().
02807 { 02808 float f; 02809 sscanf(s, "%30f", &f); 02810 o->rxgain = f; 02811 //ast_log(LOG_WARNING, "set rxgain = %f\n", f); 02812 }
static void store_rxsdtype | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2784 of file chan_usbradio.c.
References ast_log(), LOG_WARNING, chan_usbradio_pvt::rxsdtype, SD_HID, SD_HID_INVERT, SD_IGNORE, and SD_XPMR.
Referenced by store_config().
02785 { 02786 if (!strcasecmp(s,"no") || !strcasecmp(s,"SD_IGNORE")){ 02787 o->rxsdtype = SD_IGNORE; 02788 } 02789 else if (!strcasecmp(s,"usb") || !strcasecmp(s,"SD_HID")){ 02790 o->rxsdtype = SD_HID; 02791 } 02792 else if (!strcasecmp(s,"usbinvert") || !strcasecmp(s,"SD_HID_INVERT")){ 02793 o->rxsdtype = SD_HID_INVERT; 02794 } 02795 else if (!strcasecmp(s,"software") || !strcasecmp(s,"SD_XPMR")){ 02796 o->rxsdtype = SD_XPMR; 02797 } 02798 else { 02799 ast_log(LOG_WARNING,"Unrecognized rxsdtype parameter: %s\n",s); 02800 } 02801 02802 //ast_log(LOG_WARNING, "set rxsdtype = %s\n", s); 02803 }
static void store_rxvoiceadj | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2815 of file chan_usbradio.c.
References f, and chan_usbradio_pvt::rxvoiceadj.
Referenced by store_config().
02816 { 02817 float f; 02818 sscanf(s, "%30f", &f); 02819 o->rxvoiceadj = f; 02820 //ast_log(LOG_WARNING, "set rxvoiceadj = %f\n", f); 02821 }
static void store_txmixa | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2710 of file chan_usbradio.c.
References ast_log(), LOG_WARNING, TX_OUT_AUX, TX_OUT_COMPOSITE, TX_OUT_LSD, TX_OUT_OFF, TX_OUT_VOICE, and chan_usbradio_pvt::txmixa.
Referenced by store_config().
02711 { 02712 if (!strcasecmp(s,"no")){ 02713 o->txmixa = TX_OUT_OFF; 02714 } 02715 else if (!strcasecmp(s,"voice")){ 02716 o->txmixa = TX_OUT_VOICE; 02717 } 02718 else if (!strcasecmp(s,"tone")){ 02719 o->txmixa = TX_OUT_LSD; 02720 } 02721 else if (!strcasecmp(s,"composite")){ 02722 o->txmixa = TX_OUT_COMPOSITE; 02723 } 02724 else if (!strcasecmp(s,"auxvoice")){ 02725 o->txmixa = TX_OUT_AUX; 02726 } 02727 else { 02728 ast_log(LOG_WARNING,"Unrecognized txmixa parameter: %s\n",s); 02729 } 02730 02731 //ast_log(LOG_WARNING, "set txmixa = %s\n", s); 02732 }
static void store_txmixb | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2734 of file chan_usbradio.c.
References ast_log(), LOG_WARNING, TX_OUT_AUX, TX_OUT_COMPOSITE, TX_OUT_LSD, TX_OUT_OFF, TX_OUT_VOICE, and chan_usbradio_pvt::txmixb.
Referenced by store_config().
02735 { 02736 if (!strcasecmp(s,"no")){ 02737 o->txmixb = TX_OUT_OFF; 02738 } 02739 else if (!strcasecmp(s,"voice")){ 02740 o->txmixb = TX_OUT_VOICE; 02741 } 02742 else if (!strcasecmp(s,"tone")){ 02743 o->txmixb = TX_OUT_LSD; 02744 } 02745 else if (!strcasecmp(s,"composite")){ 02746 o->txmixb = TX_OUT_COMPOSITE; 02747 } 02748 else if (!strcasecmp(s,"auxvoice")){ 02749 o->txmixb = TX_OUT_AUX; 02750 } 02751 else { 02752 ast_log(LOG_WARNING,"Unrecognized txmixb parameter: %s\n",s); 02753 } 02754 02755 //ast_log(LOG_WARNING, "set txmixb = %s\n", s); 02756 }
static void store_txtoctype | ( | struct chan_usbradio_pvt * | o, | |
const char * | s | |||
) | [static] |
Definition at line 2833 of file chan_usbradio.c.
References ast_log(), LOG_WARNING, TOC_NONE, TOC_NOTONE, TOC_PHASE, and chan_usbradio_pvt::txtoctype.
Referenced by store_config().
02834 { 02835 if (!strcasecmp(s,"no") || !strcasecmp(s,"TOC_NONE")){ 02836 o->txtoctype = TOC_NONE; 02837 } 02838 else if (!strcasecmp(s,"phase") || !strcasecmp(s,"TOC_PHASE")){ 02839 o->txtoctype = TOC_PHASE; 02840 } 02841 else if (!strcasecmp(s,"notone") || !strcasecmp(s,"TOC_NOTONE")){ 02842 o->txtoctype = TOC_NOTONE; 02843 } 02844 else { 02845 ast_log(LOG_WARNING,"Unrecognized txtoctype parameter: %s\n",s); 02846 } 02847 }
static void tune_rxctcss | ( | int | fd, | |
struct chan_usbradio_pvt * | o | |||
) | [static] |
Definition at line 3010 of file chan_usbradio.c.
References ast_cli(), chan_usbradio_pvt::pmrChan, and chan_usbradio_pvt::rxctcssadj.
Referenced by radio_tune().
03011 { 03012 const int target=2400; // was 4096 pre 20080205 03013 const int tolerance=100; 03014 const float settingmin=0.1; 03015 const float settingmax=8; 03016 const float settingstart=1; 03017 const int maxtries=12; 03018 03019 float setting; 03020 int tries=0, meas; 03021 03022 ast_cli(fd,"INFO: RX CTCSS ADJUST START.\n"); 03023 ast_cli(fd,"target=%i tolerance=%i \n",target,tolerance); 03024 03025 o->pmrChan->b.tuning=1; 03026 o->pmrChan->spsMeasure->source=o->pmrChan->prxCtcssMeasure; 03027 o->pmrChan->spsMeasure->discfactor=400; 03028 o->pmrChan->spsMeasure->enabled=1; 03029 03030 setting=settingstart; 03031 03032 while(tries<maxtries) 03033 { 03034 *(o->pmrChan->prxCtcssAdjust)=setting*M_Q8; 03035 usleep(10000); 03036 o->pmrChan->spsMeasure->amax = o->pmrChan->spsMeasure->amin = 0; 03037 usleep(500000); 03038 meas = o->pmrChan->spsMeasure->apeak; 03039 ast_cli(fd,"tries=%i, setting=%f, meas=%i\n",tries,setting,meas); 03040 03041 if( meas<(target-tolerance) || meas>(target+tolerance) || tries<3){ 03042 setting=setting*target/meas; 03043 } 03044 else if(tries>4 && meas>(target-tolerance) && meas<(target+tolerance) ) 03045 { 03046 break; 03047 } 03048 if(setting<settingmin)setting=settingmin; 03049 else if(setting>settingmax)setting=settingmax; 03050 03051 tries++; 03052 } 03053 o->pmrChan->spsMeasure->enabled=0; 03054 ast_cli(fd,"DONE tries=%i, setting=%f, meas=%f\n",tries,setting,(float)meas); 03055 if( meas<(target-tolerance) || meas>(target+tolerance) ){ 03056 ast_cli(fd,"ERROR: RX CTCSS GAIN ADJUST FAILED.\n"); 03057 }else{ 03058 ast_cli(fd,"INFO: RX CTCSS GAIN ADJUST SUCCESS.\n"); 03059 o->rxctcssadj=setting; 03060 } 03061 o->pmrChan->b.tuning=0; 03062 }
static void tune_rxinput | ( | int | fd, | |
struct chan_usbradio_pvt * | o | |||
) | [static] |
Definition at line 2864 of file chan_usbradio.c.
References ast_cli(), CD_XPMR_NOISE, chan_usbradio_pvt::devicenum, chan_usbradio_pvt::micmax, MIXER_PARAM_MIC_BOOST, MIXER_PARAM_MIC_CAPTURE_VOL, chan_usbradio_pvt::pmrChan, RX_AUDIO_SPEAKER, chan_usbradio_pvt::rxboostset, chan_usbradio_pvt::rxcdtype, chan_usbradio_pvt::rxdemod, chan_usbradio_pvt::rxmixerset, and setamixer().
Referenced by radio_tune().
02865 { 02866 const int target=23000; 02867 const int tolerance=2000; 02868 const int settingmin=1; 02869 const int settingstart=2; 02870 const int maxtries=12; 02871 02872 float settingmax; 02873 02874 int setting=0, tries=0, tmpdiscfactor, meas; 02875 int tunetype=0; 02876 02877 settingmax = o->micmax; 02878 02879 if(o->pmrChan->rxDemod)tunetype=1; 02880 o->pmrChan->b.tuning=1; 02881 02882 setting = settingstart; 02883 02884 ast_cli(fd,"tune rxnoise maxtries=%i, target=%i, tolerance=%i\n",maxtries,target,tolerance); 02885 02886 while(tries<maxtries) 02887 { 02888 setamixer(o->devicenum,MIXER_PARAM_MIC_CAPTURE_VOL,setting,0); 02889 setamixer(o->devicenum,MIXER_PARAM_MIC_BOOST,o->rxboostset,0); 02890 02891 usleep(100000); 02892 if(o->rxcdtype!=CD_XPMR_NOISE || o->rxdemod==RX_AUDIO_SPEAKER) 02893 { 02894 // printf("Measure Direct Input\n"); 02895 o->pmrChan->spsMeasure->source = o->pmrChan->spsRx->source; 02896 o->pmrChan->spsMeasure->discfactor=2000; 02897 o->pmrChan->spsMeasure->enabled=1; 02898 o->pmrChan->spsMeasure->amax = o->pmrChan->spsMeasure->amin = 0; 02899 usleep(400000); 02900 meas=o->pmrChan->spsMeasure->apeak; 02901 o->pmrChan->spsMeasure->enabled=0; 02902 } 02903 else 02904 { 02905 // printf("Measure HF Noise\n"); 02906 tmpdiscfactor=o->pmrChan->spsRx->discfactor; 02907 o->pmrChan->spsRx->discfactor=(i16)2000; 02908 o->pmrChan->spsRx->discounteru=o->pmrChan->spsRx->discounterl=0; 02909 o->pmrChan->spsRx->amax=o->pmrChan->spsRx->amin=0; 02910 usleep(200000); 02911 meas=o->pmrChan->rxRssi; 02912 o->pmrChan->spsRx->discfactor=tmpdiscfactor; 02913 o->pmrChan->spsRx->discounteru=o->pmrChan->spsRx->discounterl=0; 02914 o->pmrChan->spsRx->amax=o->pmrChan->spsRx->amin=0; 02915 } 02916 if(!meas)meas++; 02917 ast_cli(fd,"tries=%i, setting=%i, meas=%i\n",tries,setting,meas); 02918 02919 if( meas<(target-tolerance) || meas>(target+tolerance) || tries<3){ 02920 setting=setting*target/meas; 02921 } 02922 else if(tries>4 && meas>(target-tolerance) && meas<(target+tolerance) ) 02923 { 02924 break; 02925 } 02926 02927 if(setting<settingmin)setting=settingmin; 02928 else if(setting>settingmax)setting=settingmax; 02929 02930 tries++; 02931 } 02932 ast_cli(fd,"DONE tries=%i, setting=%i, meas=%i\n",tries, 02933 (setting * 1000) / o->micmax,meas); 02934 if( meas<(target-tolerance) || meas>(target+tolerance) ){ 02935 ast_cli(fd,"ERROR: RX INPUT ADJUST FAILED.\n"); 02936 }else{ 02937 ast_cli(fd,"INFO: RX INPUT ADJUST SUCCESS.\n"); 02938 o->rxmixerset=(setting * 1000) / o->micmax; 02939 } 02940 o->pmrChan->b.tuning=0; 02941 }
static void tune_rxvoice | ( | int | fd, | |
struct chan_usbradio_pvt * | o | |||
) | [static] |
Definition at line 2944 of file chan_usbradio.c.
References ast_cli(), chan_usbradio_pvt::pmrChan, and chan_usbradio_pvt::rxvoiceadj.
Referenced by radio_tune().
02945 { 02946 const int target=7200; // peak 02947 const int tolerance=360; // peak to peak 02948 const float settingmin=0.1; 02949 const float settingmax=4; 02950 const float settingstart=1; 02951 const int maxtries=12; 02952 02953 float setting; 02954 02955 int tries=0, meas; 02956 02957 ast_cli(fd,"INFO: RX VOICE ADJUST START.\n"); 02958 ast_cli(fd,"target=%i tolerance=%i \n",target,tolerance); 02959 02960 o->pmrChan->b.tuning=1; 02961 if(!o->pmrChan->spsMeasure) 02962 ast_cli(fd,"ERROR: NO MEASURE BLOCK.\n"); 02963 02964 if(!o->pmrChan->spsMeasure->source || !o->pmrChan->prxVoiceAdjust ) 02965 ast_cli(fd,"ERROR: NO SOURCE OR MEASURE SETTING.\n"); 02966 02967 o->pmrChan->spsMeasure->source=o->pmrChan->spsRxOut->sink; 02968 o->pmrChan->spsMeasure->enabled=1; 02969 o->pmrChan->spsMeasure->discfactor=1000; 02970 02971 setting=settingstart; 02972 02973 // ast_cli(fd,"ERROR: NO MEASURE BLOCK.\n"); 02974 02975 while(tries<maxtries) 02976 { 02977 *(o->pmrChan->prxVoiceAdjust)=setting*M_Q8; 02978 usleep(10000); 02979 o->pmrChan->spsMeasure->amax = o->pmrChan->spsMeasure->amin = 0; 02980 usleep(1000000); 02981 meas = o->pmrChan->spsMeasure->apeak; 02982 ast_cli(fd,"tries=%i, setting=%f, meas=%i\n",tries,setting,meas); 02983 02984 if( meas<(target-tolerance) || meas>(target+tolerance) || tries<3){ 02985 setting=setting*target/meas; 02986 } 02987 else if(tries>4 && meas>(target-tolerance) && meas<(target+tolerance) ) 02988 { 02989 break; 02990 } 02991 if(setting<settingmin)setting=settingmin; 02992 else if(setting>settingmax)setting=settingmax; 02993 02994 tries++; 02995 } 02996 02997 o->pmrChan->spsMeasure->enabled=0; 02998 02999 ast_cli(fd,"DONE tries=%i, setting=%f, meas=%f\n",tries,setting,(float)meas); 03000 if( meas<(target-tolerance) || meas>(target+tolerance) ){ 03001 ast_cli(fd,"ERROR: RX VOICE GAIN ADJUST FAILED.\n"); 03002 }else{ 03003 ast_cli(fd,"INFO: RX VOICE GAIN ADJUST SUCCESS.\n"); 03004 o->rxvoiceadj=setting; 03005 } 03006 o->pmrChan->b.tuning=0; 03007 }
static void tune_txoutput | ( | struct chan_usbradio_pvt * | o, | |
int | value, | |||
int | fd | |||
) | [static] |
Definition at line 2850 of file chan_usbradio.c.
References ast_cli(), chan_usbradio_pvt::name, chan_usbradio_pvt::pmrChan, and chan_usbradio_pvt::txtestkey.
Referenced by radio_tune().
02851 { 02852 o->txtestkey=1; 02853 o->pmrChan->txPttIn=1; 02854 TxTestTone(o->pmrChan, 1); // generate 1KHz tone at 7200 peak 02855 if (fd > 0) ast_cli(fd,"Tone output starting on channel %s...\n",o->name); 02856 usleep(5000000); 02857 TxTestTone(o->pmrChan, 0); 02858 if (fd > 0) ast_cli(fd,"Tone output ending on channel %s...\n",o->name); 02859 o->pmrChan->txPttIn=0; 02860 o->txtestkey=0; 02861 }
static void tune_write | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 3066 of file chan_usbradio.c.
References ast_mutex_lock, ast_mutex_unlock, chan_usbradio_pvt::devicenum, chan_usbradio_pvt::devstr, chan_usbradio_pvt::eeprom, EEPROM_RXCTCSSADJ, EEPROM_RXMIXERSET, EEPROM_RXSQUELCHADJ, EEPROM_RXVOICEADJ, EEPROM_TXCTCSSADJ, EEPROM_TXMIXASET, EEPROM_TXMIXBSET, chan_usbradio_pvt::eepromctl, chan_usbradio_pvt::eepromlock, chan_usbradio_pvt::name, chan_usbradio_pvt::rxctcssadj, chan_usbradio_pvt::rxmixerset, chan_usbradio_pvt::rxsquelchadj, chan_usbradio_pvt::rxvoiceadj, chan_usbradio_pvt::txctcssadj, chan_usbradio_pvt::txmixaset, chan_usbradio_pvt::txmixbset, and chan_usbradio_pvt::wanteeprom.
Referenced by radio_tune().
03067 { 03068 FILE *fp; 03069 char fname[200]; 03070 03071 snprintf(fname,sizeof(fname) - 1,"/etc/asterisk/usbradio_tune_%s.conf",o->name); 03072 fp = fopen(fname,"w"); 03073 03074 fprintf(fp,"[%s]\n",o->name); 03075 03076 fprintf(fp,"; name=%s\n",o->name); 03077 fprintf(fp,"; devicenum=%i\n",o->devicenum); 03078 fprintf(fp,"devstr=%s\n",o->devstr); 03079 fprintf(fp,"rxmixerset=%i\n",o->rxmixerset); 03080 fprintf(fp,"txmixaset=%i\n",o->txmixaset); 03081 fprintf(fp,"txmixbset=%i\n",o->txmixbset); 03082 fprintf(fp,"rxvoiceadj=%f\n",o->rxvoiceadj); 03083 fprintf(fp,"rxctcssadj=%f\n",o->rxctcssadj); 03084 fprintf(fp,"txctcssadj=%i\n",o->txctcssadj); 03085 fprintf(fp,"rxsquelchadj=%i\n",o->rxsquelchadj); 03086 fclose(fp); 03087 03088 if(o->wanteeprom) 03089 { 03090 ast_mutex_lock(&o->eepromlock); 03091 while(o->eepromctl) 03092 { 03093 ast_mutex_unlock(&o->eepromlock); 03094 usleep(10000); 03095 ast_mutex_lock(&o->eepromlock); 03096 } 03097 o->eeprom[EEPROM_RXMIXERSET] = o->rxmixerset; 03098 o->eeprom[EEPROM_TXMIXASET] = o->txmixaset; 03099 o->eeprom[EEPROM_TXMIXBSET] = o->txmixbset; 03100 memcpy(&o->eeprom[EEPROM_RXVOICEADJ],&o->rxvoiceadj,sizeof(float)); 03101 memcpy(&o->eeprom[EEPROM_RXCTCSSADJ],&o->rxctcssadj,sizeof(float)); 03102 o->eeprom[EEPROM_TXCTCSSADJ] = o->txctcssadj; 03103 o->eeprom[EEPROM_RXSQUELCHADJ] = o->rxsquelchadj; 03104 o->eepromctl = 2; /* request a write */ 03105 ast_mutex_unlock(&o->eepromlock); 03106 } 03107 }
static int unload_module | ( | void | ) | [static] |
Definition at line 3987 of file chan_usbradio.c.
References ARRAY_LEN, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_dsp_free(), ast_log(), ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, cli_usbradio, chan_usbradio_pvt::dsp, frxcapraw, frxcaptrace, frxoutraw, ftxcapraw, ftxcaptrace, ftxoutraw, LOG_WARNING, chan_usbradio_pvt::next, chan_usbradio_pvt::owner, chan_usbradio_pvt::pmrChan, chan_usbradio_pvt::sounddev, usbradio_default, and usbradio_tech.
03988 { 03989 struct chan_usbradio_pvt *o; 03990 03991 ast_log(LOG_WARNING, "unload_module() called\n"); 03992 03993 ast_channel_unregister(&usbradio_tech); 03994 ast_cli_unregister_multiple(cli_usbradio, ARRAY_LEN(cli_usbradio)); 03995 03996 for (o = usbradio_default.next; o; o = o->next) { 03997 03998 ast_log(LOG_WARNING, "destroyPmrChannel() called\n"); 03999 if(o->pmrChan)destroyPmrChannel(o->pmrChan); 04000 04001 #if DEBUG_CAPTURES == 1 04002 if (frxcapraw) { fclose(frxcapraw); frxcapraw = NULL; } 04003 if (frxcaptrace) { fclose(frxcaptrace); frxcaptrace = NULL; } 04004 if (frxoutraw) { fclose(frxoutraw); frxoutraw = NULL; } 04005 if (ftxcapraw) { fclose(ftxcapraw); ftxcapraw = NULL; } 04006 if (ftxcaptrace) { fclose(ftxcaptrace); ftxcaptrace = NULL; } 04007 if (ftxoutraw) { fclose(ftxoutraw); ftxoutraw = NULL; } 04008 #endif 04009 04010 close(o->sounddev); 04011 #ifndef NEW_ASTERISK 04012 if (o->sndcmd[0] > 0) { 04013 close(o->sndcmd[0]); 04014 close(o->sndcmd[1]); 04015 } 04016 #endif 04017 if (o->dsp) ast_dsp_free(o->dsp); 04018 if (o->owner) 04019 ast_softhangup(o->owner, AST_SOFTHANGUP_APPUNLOAD); 04020 if (o->owner) /* XXX how ??? */ 04021 return -1; 04022 /* XXX what about the thread ? */ 04023 /* XXX what about the memory allocated ? */ 04024 } 04025 return 0; 04026 }
static int usb_get_usbdev | ( | char * | devstr | ) | [static] |
Definition at line 1023 of file chan_usbradio.c.
References str.
Referenced by store_config().
01024 { 01025 int i; 01026 char str[200],desdev[200],*cp; 01027 01028 for(i = 0;i < 32; i++) 01029 { 01030 if (i) sprintf(str,"/sys/class/sound/dsp%d/device",i); 01031 else strcpy(str,"/sys/class/sound/dsp/device"); 01032 memset(desdev,0,sizeof(desdev)); 01033 if (readlink(str,desdev,sizeof(desdev) - 1) == -1) 01034 { 01035 sprintf(str,"/sys/class/sound/controlC%d/device",i); 01036 memset(desdev,0,sizeof(desdev)); 01037 if (readlink(str,desdev,sizeof(desdev) - 1) == -1) continue; 01038 } 01039 cp = strrchr(desdev,'/'); 01040 if (cp) *cp = 0; else continue; 01041 cp = strrchr(desdev,'/'); 01042 if (!cp) continue; 01043 cp++; 01044 if (!strcasecmp(cp,devstr)) break; 01045 } 01046 if (i >= 32) return -1; 01047 return i; 01048 01049 }
static int usb_list_check | ( | char * | devstr | ) | [static] |
Definition at line 1051 of file chan_usbradio.c.
References usb_device_list.
Referenced by load_module(), and store_config().
01052 { 01053 01054 char *s = usb_device_list; 01055 01056 if (!s) return(0); 01057 while(*s) 01058 { 01059 if (!strcasecmp(s,devstr)) return(1); 01060 s += strlen(s) + 1; 01061 } 01062 return(0); 01063 }
static int usbradio_answer | ( | struct ast_channel * | c | ) | [static] |
Definition at line 1700 of file chan_usbradio.c.
References ast_setstate(), AST_STATE_UP, and ast_channel::tech_pvt.
01701 { 01702 #ifndef NEW_ASTERISK 01703 struct chan_usbradio_pvt *o = c->tech_pvt; 01704 #endif 01705 01706 ast_setstate(c, AST_STATE_UP); 01707 #ifndef NEW_ASTERISK 01708 o->cursound = -1; 01709 o->nosound = 0; 01710 #endif 01711 return 0; 01712 }
static int usbradio_call | ( | struct ast_channel * | c, | |
char * | dest, | |||
int | timeout | |||
) | [static] |
Definition at line 1686 of file chan_usbradio.c.
References ast_pthread_create_background, ast_setstate(), AST_STATE_UP, hidthread(), chan_usbradio_pvt::hidthread, chan_usbradio_pvt::lasthidtime, chan_usbradio_pvt::stophid, and ast_channel::tech_pvt.
01687 { 01688 struct chan_usbradio_pvt *o = c->tech_pvt; 01689 01690 o->stophid = 0; 01691 time(&o->lasthidtime); 01692 ast_pthread_create_background(&o->hidthread, NULL, hidthread, o); 01693 ast_setstate(c, AST_STATE_UP); 01694 return 0; 01695 }
static int usbradio_digit_begin | ( | struct ast_channel * | c, | |
char | digit | |||
) | [static] |
static int usbradio_digit_end | ( | struct ast_channel * | c, | |
char | digit, | |||
unsigned int | duration | |||
) | [static] |
Definition at line 1612 of file chan_usbradio.c.
References ast_verbose.
01613 { 01614 /* no better use for received digits than print them */ 01615 ast_verbose(" << Console Received digit %c of duration %u ms >> \n", 01616 digit, duration); 01617 return 0; 01618 }
static int usbradio_fixup | ( | struct ast_channel * | oldchan, | |
struct ast_channel * | newchan | |||
) | [static] |
Definition at line 2105 of file chan_usbradio.c.
References ast_log(), LOG_WARNING, chan_usbradio_pvt::owner, and ast_channel::tech_pvt.
02106 { 02107 struct chan_usbradio_pvt *o = newchan->tech_pvt; 02108 ast_log(LOG_WARNING,"usbradio_fixup()\n"); 02109 o->owner = newchan; 02110 return 0; 02111 }
static int usbradio_hangup | ( | struct ast_channel * | c | ) | [static] |
Definition at line 1714 of file chan_usbradio.c.
References AST_CONTROL_CONGESTION, ast_module_unref(), chan_usbradio_pvt::autoanswer, chan_usbradio_pvt::autohangup, chan_usbradio_pvt::hidthread, chan_usbradio_pvt::hookstate, O_CLOSE, chan_usbradio_pvt::owner, ring(), setformat(), chan_usbradio_pvt::stophid, and ast_channel::tech_pvt.
01715 { 01716 struct chan_usbradio_pvt *o = c->tech_pvt; 01717 01718 //ast_log(LOG_NOTICE, "usbradio_hangup()\n"); 01719 #ifndef NEW_ASTERISK 01720 o->cursound = -1; 01721 o->nosound = 0; 01722 #endif 01723 c->tech_pvt = NULL; 01724 o->owner = NULL; 01725 ast_module_unref(ast_module_info->self); 01726 if (o->hookstate) { 01727 if (o->autoanswer || o->autohangup) { 01728 /* Assume auto-hangup too */ 01729 o->hookstate = 0; 01730 setformat(o, O_CLOSE); 01731 } else { 01732 /* Make congestion noise */ 01733 ring(o, AST_CONTROL_CONGESTION); 01734 } 01735 } 01736 o->stophid = 1; 01737 pthread_join(o->hidthread,NULL); 01738 return 0; 01739 }
static int usbradio_indicate | ( | struct ast_channel * | chan, | |
int | cond, | |||
const void * | data, | |||
size_t | datalen | |||
) | [static] |
Definition at line 2113 of file chan_usbradio.c.
References AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_log(), ast_moh_start(), ast_moh_stop(), ast_verbose, chan_usbradio_pvt::debuglevel, LOG_WARNING, chan_usbradio_pvt::mohinterpret, ast_channel::name, ring(), ast_channel::tech_pvt, and chan_usbradio_pvt::txkeyed.
02114 { 02115 struct chan_usbradio_pvt *o = c->tech_pvt; 02116 int res = -1; 02117 02118 switch (cond) { 02119 case AST_CONTROL_BUSY: 02120 case AST_CONTROL_CONGESTION: 02121 case AST_CONTROL_RINGING: 02122 res = cond; 02123 break; 02124 case AST_CONTROL_INCOMPLETE: 02125 res = AST_CONTROL_CONGESTION; 02126 break; 02127 case -1: 02128 #ifndef NEW_ASTERISK 02129 o->cursound = -1; 02130 o->nosound = 0; /* when cursound is -1 nosound must be 0 */ 02131 #endif 02132 return 0; 02133 02134 case AST_CONTROL_VIDUPDATE: 02135 res = -1; 02136 break; 02137 case AST_CONTROL_HOLD: 02138 ast_verbose(" << Console Has Been Placed on Hold >> \n"); 02139 ast_moh_start(c, data, o->mohinterpret); 02140 break; 02141 case AST_CONTROL_UNHOLD: 02142 ast_verbose(" << Console Has Been Retrieved from Hold >> \n"); 02143 ast_moh_stop(c); 02144 break; 02145 case AST_CONTROL_PROCEEDING: 02146 ast_verbose(" << Call Proceeding... >> \n"); 02147 ast_moh_stop(c); 02148 break; 02149 case AST_CONTROL_PROGRESS: 02150 ast_verbose(" << Call Progress... >> \n"); 02151 ast_moh_stop(c); 02152 break; 02153 case AST_CONTROL_RADIO_KEY: 02154 o->txkeyed = 1; 02155 if(o->debuglevel)ast_verbose(" << AST_CONTROL_RADIO_KEY Radio Transmit On. >> \n"); 02156 break; 02157 case AST_CONTROL_RADIO_UNKEY: 02158 o->txkeyed = 0; 02159 if(o->debuglevel)ast_verbose(" << AST_CONTROL_RADIO_UNKEY Radio Transmit Off. >> \n"); 02160 break; 02161 default: 02162 ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, c->name); 02163 return -1; 02164 } 02165 02166 if (res > -1) 02167 ring(o, res); 02168 02169 return 0; 02170 }
static struct ast_channel* usbradio_new | ( | struct chan_usbradio_pvt * | o, | |
char * | ext, | |||
char * | ctx, | |||
int | state, | |||
const char * | linkedid | |||
) | [static] |
Definition at line 2175 of file chan_usbradio.c.
References ast_party_caller::ani, ast_channel_alloc, AST_FORMAT_SLINEAR, ast_hangup(), ast_jb_configure(), ast_log(), ast_module_ref(), ast_pbx_start(), AST_STATE_DOWN, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_channel::caller, chan_usbradio_pvt::cid_name, chan_usbradio_pvt::cid_num, ast_channel::dialed, ast_channel::fds, global_jbconf, language, chan_usbradio_pvt::language, LOG_WARNING, chan_usbradio_pvt::name, ast_channel::nativeformats, ast_party_dialed::number, ast_party_id::number, chan_usbradio_pvt::owner, ast_channel::readformat, setformat(), chan_usbradio_pvt::sounddev, ast_party_dialed::str, ast_party_number::str, ast_channel::tech, ast_channel::tech_pvt, usbradio_tech, ast_party_number::valid, and ast_channel::writeformat.
Referenced by usbradio_request().
02176 { 02177 struct ast_channel *c; 02178 02179 c = ast_channel_alloc(1, state, o->cid_num, o->cid_name, "", ext, ctx, linkedid, 0, "Radio/%s", o->name); 02180 if (c == NULL) 02181 return NULL; 02182 c->tech = &usbradio_tech; 02183 if (o->sounddev < 0) 02184 setformat(o, O_RDWR); 02185 c->fds[0] = o->sounddev; /* -1 if device closed, override later */ 02186 c->nativeformats = AST_FORMAT_SLINEAR; 02187 c->readformat = AST_FORMAT_SLINEAR; 02188 c->writeformat = AST_FORMAT_SLINEAR; 02189 c->tech_pvt = o; 02190 02191 if (!ast_strlen_zero(o->language)) 02192 ast_string_field_set(c, language, o->language); 02193 /* Don't use ast_set_callerid() here because it will 02194 * generate a needless NewCallerID event */ 02195 if (!ast_strlen_zero(o->cid_num)) { 02196 c->caller.ani.number.valid = 1; 02197 c->caller.ani.number.str = ast_strdup(o->cid_num); 02198 } 02199 if (!ast_strlen_zero(ext)) { 02200 c->dialed.number.str = ast_strdup(ext); 02201 } 02202 02203 o->owner = c; 02204 ast_module_ref(ast_module_info->self); 02205 ast_jb_configure(c, &global_jbconf); 02206 if (state != AST_STATE_DOWN) { 02207 if (ast_pbx_start(c)) { 02208 ast_log(LOG_WARNING, "Unable to start PBX on %s\n", c->name); 02209 ast_hangup(c); 02210 o->owner = c = NULL; 02211 /* XXX what about the channel itself ? */ 02212 /* XXX what about usecnt ? */ 02213 } 02214 } 02215 02216 return c; 02217 }
static struct ast_frame * usbradio_read | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 1786 of file chan_usbradio.c.
References ast_channel::_state, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, ast_dsp_process(), AST_FORMAT_SLINEAR, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_NULL, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), ast_queue_frame(), AST_STATE_UP, chan_usbradio_pvt::b, chan_usbradio_pvt::boost, BOOST_SCALE, CD_HID, CD_HID_INVERT, CD_XPMR_NOISE, CD_XPMR_VOX, ast_frame::data, ast_frame::datalen, chan_usbradio_pvt::debuglevel, chan_usbradio_pvt::dsp, errno, f, ast_frame::frametype, frxcapraw, frxcaptrace, frxoutraw, ftxcaptrace, ftxoutraw, ast_frame_subclass::integer, kickptt(), chan_usbradio_pvt::lasthidtime, chan_usbradio_pvt::lastrx, LOG_ERROR, LOG_NOTICE, LOG_WARNING, chan_usbradio_pvt::mute, ast_channel::name, chan_usbradio_pvt::name, chan_usbradio_pvt::owner, chan_usbradio_pvt::pmrChan, ast_frame::ptr, chan_usbradio_pvt::radioduplex, chan_usbradio_pvt::read_f, READERR_THRESHOLD, chan_usbradio_pvt::readerrs, chan_usbradio_pvt::readpos, RX_CAP_OUT_FILE, chan_usbradio_pvt::rxcap2, chan_usbradio_pvt::rxcapraw, chan_usbradio_pvt::rxcarrierdetect, chan_usbradio_pvt::rxcdtype, chan_usbradio_pvt::rxctcssdecode, chan_usbradio_pvt::rxctcssfreq, chan_usbradio_pvt::rxdcsdecode, chan_usbradio_pvt::rxhidsq, chan_usbradio_pvt::rxkeyed, chan_usbradio_pvt::rxlsddecode, soundcard_writeframe(), chan_usbradio_pvt::sounddev, ast_frame::subclass, ast_channel::tech_pvt, traceusb2, TX_CAP_OUT_FILE, chan_usbradio_pvt::txcap2, chan_usbradio_pvt::txkeyed, chan_usbradio_pvt::txtestkey, ast_channel_tech::type, chan_usbradio_pvt::usbradio_read_buf, chan_usbradio_pvt::usbradio_read_buf_8k, usbradio_tech, chan_usbradio_pvt::usbradio_write_buf, chan_usbradio_pvt::usbradio_write_buf_1, and chan_usbradio_pvt::usbradio_write_dst.
01787 { 01788 int res, src, datalen, oldpttout; 01789 int cd,sd; 01790 struct chan_usbradio_pvt *o = c->tech_pvt; 01791 struct ast_frame *f = &o->read_f,*f1; 01792 struct ast_frame wf = { AST_FRAME_CONTROL }; 01793 time_t now; 01794 01795 traceusb2(("usbradio_read()\n")); 01796 01797 if (o->lasthidtime) 01798 { 01799 time(&now); 01800 if ((now - o->lasthidtime) > 3) 01801 { 01802 ast_log(LOG_ERROR,"HID process has died or something!!\n"); 01803 return NULL; 01804 } 01805 } 01806 /* XXX can be simplified returning &ast_null_frame */ 01807 /* prepare a NULL frame in case we don't have enough data to return */ 01808 memset(f, '\0', sizeof(struct ast_frame)); 01809 f->frametype = AST_FRAME_NULL; 01810 f->src = usbradio_tech.type; 01811 01812 res = read(o->sounddev, o->usbradio_read_buf + o->readpos, 01813 sizeof(o->usbradio_read_buf) - o->readpos); 01814 if (res < 0) /* audio data not ready, return a NULL frame */ 01815 { 01816 if (errno != EAGAIN) return NULL; 01817 if (o->readerrs++ > READERR_THRESHOLD) 01818 { 01819 ast_log(LOG_ERROR,"Stuck USB read channel [%s], un-sticking it!\n",o->name); 01820 o->readerrs = 0; 01821 return NULL; 01822 } 01823 if (o->readerrs == 1) 01824 ast_log(LOG_WARNING,"Possibly stuck USB read channel. [%s]\n",o->name); 01825 return f; 01826 } 01827 if (o->readerrs) ast_log(LOG_WARNING,"Nope, USB read channel [%s] wasn't stuck after all.\n",o->name); 01828 o->readerrs = 0; 01829 o->readpos += res; 01830 if (o->readpos < sizeof(o->usbradio_read_buf)) /* not enough samples */ 01831 return f; 01832 01833 if (o->mute) 01834 return f; 01835 01836 #if DEBUG_CAPTURES == 1 01837 if ((o->b.rxcapraw && frxcapraw) && (fwrite((o->usbradio_read_buf + AST_FRIENDLY_OFFSET),1,FRAME_SIZE * 2 * 2 * 6,frxcapraw) != FRAME_SIZE * 2 * 2 * 6)) { 01838 ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno)); 01839 } 01840 #endif 01841 01842 #if 1 01843 if(o->txkeyed||o->txtestkey) 01844 { 01845 if(!o->pmrChan->txPttIn) 01846 { 01847 o->pmrChan->txPttIn=1; 01848 if(o->debuglevel) ast_log(LOG_NOTICE,"txPttIn = %i, chan %s\n",o->pmrChan->txPttIn,o->owner->name); 01849 } 01850 } 01851 else if(o->pmrChan->txPttIn) 01852 { 01853 o->pmrChan->txPttIn=0; 01854 if(o->debuglevel) ast_log(LOG_NOTICE,"txPttIn = %i, chan %s\n",o->pmrChan->txPttIn,o->owner->name); 01855 } 01856 oldpttout = o->pmrChan->txPttOut; 01857 01858 PmrRx( o->pmrChan, 01859 (i16 *)(o->usbradio_read_buf + AST_FRIENDLY_OFFSET), 01860 (i16 *)(o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET), 01861 (i16 *)(o->usbradio_write_buf_1)); 01862 01863 if (oldpttout != o->pmrChan->txPttOut) 01864 { 01865 if(o->debuglevel) ast_log(LOG_NOTICE,"txPttOut = %i, chan %s\n",o->pmrChan->txPttOut,o->owner->name); 01866 kickptt(o); 01867 } 01868 01869 #if 0 // to write 48KS/s stereo tx data to a file 01870 if (!ftxoutraw) ftxoutraw = fopen(TX_CAP_OUT_FILE,"w"); 01871 if (ftxoutraw) fwrite(o->usbradio_write_buf_1,1,FRAME_SIZE * 2 * 6,ftxoutraw); 01872 #endif 01873 01874 #if DEBUG_CAPTURES == 1 && XPMR_DEBUG0 == 1 01875 if ((o->b.txcap2 && ftxcaptrace) && (fwrite((o->pmrChan->ptxDebug),1,FRAME_SIZE * 2 * 16,ftxcaptrace) != FRAME_SIZE * 2 * 16)) { 01876 ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno)); 01877 } 01878 #endif 01879 01880 // 160 samples * 2 bytes/sample * 2 chan * 6x oversampling to 48KS/s 01881 datalen = FRAME_SIZE * 24; 01882 src = 0; /* read position into f->data */ 01883 while (src < datalen) 01884 { 01885 /* Compute spare room in the buffer */ 01886 int l = sizeof(o->usbradio_write_buf) - o->usbradio_write_dst; 01887 01888 if (datalen - src >= l) 01889 { 01890 /* enough to fill a frame */ 01891 memcpy(o->usbradio_write_buf + o->usbradio_write_dst, o->usbradio_write_buf_1 + src, l); 01892 soundcard_writeframe(o, (short *) o->usbradio_write_buf); 01893 src += l; 01894 o->usbradio_write_dst = 0; 01895 } 01896 else 01897 { 01898 /* copy residue */ 01899 l = datalen - src; 01900 memcpy(o->usbradio_write_buf + o->usbradio_write_dst, o->usbradio_write_buf_1 + src, l); 01901 src += l; /* but really, we are done */ 01902 o->usbradio_write_dst += l; 01903 } 01904 } 01905 #else 01906 static FILE *hInput; 01907 i16 iBuff[FRAME_SIZE*2*6]; 01908 01909 o->pmrChan->b.rxCapture=1; 01910 01911 if(!hInput) 01912 { 01913 hInput = fopen("/usr/src/xpmr/testdata/rx_in.pcm","r"); 01914 if(!hInput) 01915 { 01916 printf(" Input Data File Not Found.\n"); 01917 return 0; 01918 } 01919 } 01920 01921 if(0==fread((void *)iBuff,2,FRAME_SIZE*2*6,hInput))exit; 01922 01923 PmrRx( o->pmrChan, 01924 (i16 *)iBuff, 01925 (i16 *)(o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET)); 01926 01927 #endif 01928 01929 #if 0 01930 if (!frxoutraw) frxoutraw = fopen(RX_CAP_OUT_FILE,"w"); 01931 if (frxoutraw) fwrite((o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET),1,FRAME_SIZE * 2,frxoutraw); 01932 #endif 01933 01934 #if DEBUG_CAPTURES == 1 && XPMR_DEBUG0 == 1 01935 if ((frxcaptrace && o->b.rxcap2 && o->pmrChan->b.radioactive) && (fwrite((o->pmrChan->prxDebug),1,FRAME_SIZE * 2 * 16,frxcaptrace) != FRAME_SIZE * 2 * 16 )) { 01936 ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno)); 01937 } 01938 #endif 01939 01940 cd = 0; 01941 if(o->rxcdtype==CD_HID && (o->pmrChan->rxExtCarrierDetect!=o->rxhidsq)) 01942 o->pmrChan->rxExtCarrierDetect=o->rxhidsq; 01943 01944 if(o->rxcdtype==CD_HID_INVERT && (o->pmrChan->rxExtCarrierDetect==o->rxhidsq)) 01945 o->pmrChan->rxExtCarrierDetect=!o->rxhidsq; 01946 01947 if( (o->rxcdtype==CD_HID && o->rxhidsq) || 01948 (o->rxcdtype==CD_HID_INVERT && !o->rxhidsq) || 01949 (o->rxcdtype==CD_XPMR_NOISE && o->pmrChan->rxCarrierDetect) || 01950 (o->rxcdtype==CD_XPMR_VOX && o->pmrChan->rxCarrierDetect) 01951 ) 01952 { 01953 if (!o->pmrChan->txPttOut || o->radioduplex)cd=1; 01954 } 01955 else 01956 { 01957 cd=0; 01958 } 01959 01960 if(cd!=o->rxcarrierdetect) 01961 { 01962 o->rxcarrierdetect=cd; 01963 if(o->debuglevel) ast_log(LOG_NOTICE,"rxcarrierdetect = %i, chan %s\n",cd,o->owner->name); 01964 // printf("rxcarrierdetect = %i, chan %s\n",res,o->owner->name); 01965 } 01966 01967 if(o->pmrChan->b.ctcssRxEnable && o->pmrChan->rxCtcss->decode!=o->rxctcssdecode) 01968 { 01969 if(o->debuglevel)ast_log(LOG_NOTICE,"rxctcssdecode = %i, chan %s\n",o->pmrChan->rxCtcss->decode,o->owner->name); 01970 // printf("rxctcssdecode = %i, chan %s\n",o->pmrChan->rxCtcss->decode,o->owner->name); 01971 o->rxctcssdecode=o->pmrChan->rxCtcss->decode; 01972 strcpy(o->rxctcssfreq, o->pmrChan->rxctcssfreq); 01973 } 01974 01975 #ifndef HAVE_XPMRX 01976 if( !o->pmrChan->b.ctcssRxEnable || 01977 ( o->pmrChan->b.ctcssRxEnable && 01978 o->pmrChan->rxCtcss->decode>CTCSS_NULL && 01979 o->pmrChan->smode==SMODE_CTCSS ) 01980 ) 01981 { 01982 sd=1; 01983 } 01984 else 01985 { 01986 sd=0; 01987 } 01988 #else 01989 if( (!o->pmrChan->b.ctcssRxEnable && !o->pmrChan->b.dcsRxEnable && !o->pmrChan->b.lmrRxEnable) || 01990 ( o->pmrChan->b.ctcssRxEnable && 01991 o->pmrChan->rxCtcss->decode>CTCSS_NULL && 01992 o->pmrChan->smode==SMODE_CTCSS ) || 01993 ( o->pmrChan->b.dcsRxEnable && 01994 o->pmrChan->decDcs->decode > 0 && 01995 o->pmrChan->smode==SMODE_DCS ) 01996 ) 01997 { 01998 sd=1; 01999 } 02000 else 02001 { 02002 sd=0; 02003 } 02004 02005 if(o->pmrChan->decDcs->decode!=o->rxdcsdecode) 02006 { 02007 if(o->debuglevel)ast_log(LOG_NOTICE,"rxdcsdecode = %s, chan %s\n",o->pmrChan->rxctcssfreq,o->owner->name); 02008 // printf("rxctcssdecode = %i, chan %s\n",o->pmrChan->rxCtcss->decode,o->owner->name); 02009 o->rxdcsdecode=o->pmrChan->decDcs->decode; 02010 strcpy(o->rxctcssfreq, o->pmrChan->rxctcssfreq); 02011 } 02012 02013 if(o->pmrChan->rptnum && (o->pmrChan->pLsdCtl->cs[o->pmrChan->rptnum].b.rxkeyed != o->rxlsddecode)) 02014 { 02015 if(o->debuglevel)ast_log(LOG_NOTICE,"rxLSDecode = %s, chan %s\n",o->pmrChan->rxctcssfreq,o->owner->name); 02016 o->rxlsddecode=o->pmrChan->pLsdCtl->cs[o->pmrChan->rptnum].b.rxkeyed; 02017 strcpy(o->rxctcssfreq, o->pmrChan->rxctcssfreq); 02018 } 02019 02020 if( (o->pmrChan->rptnum>0 && o->pmrChan->smode==SMODE_LSD && o->pmrChan->pLsdCtl->cs[o->pmrChan->rptnum].b.rxkeyed)|| 02021 (o->pmrChan->smode==SMODE_DCS && o->pmrChan->decDcs->decode>0) ) 02022 { 02023 sd=1; 02024 } 02025 #endif 02026 02027 if ( cd && sd ) 02028 { 02029 //if(!o->rxkeyed)o->pmrChan->dd.b.doitnow=1; 02030 if(!o->rxkeyed && o->debuglevel)ast_log(LOG_NOTICE,"o->rxkeyed = 1, chan %s\n", o->owner->name); 02031 o->rxkeyed = 1; 02032 } 02033 else 02034 { 02035 //if(o->rxkeyed)o->pmrChan->dd.b.doitnow=1; 02036 if(o->rxkeyed && o->debuglevel)ast_log(LOG_NOTICE,"o->rxkeyed = 0, chan %s\n",o->owner->name); 02037 o->rxkeyed = 0; 02038 } 02039 02040 // provide rx signal detect conditions 02041 if (o->lastrx && (!o->rxkeyed)) 02042 { 02043 o->lastrx = 0; 02044 //printf("AST_CONTROL_RADIO_UNKEY\n"); 02045 wf.subclass.integer = AST_CONTROL_RADIO_UNKEY; 02046 ast_queue_frame(o->owner, &wf); 02047 } 02048 else if ((!o->lastrx) && (o->rxkeyed)) 02049 { 02050 o->lastrx = 1; 02051 //printf("AST_CONTROL_RADIO_KEY\n"); 02052 wf.subclass.integer = AST_CONTROL_RADIO_KEY; 02053 if(o->rxctcssdecode) 02054 { 02055 wf.data.ptr = o->rxctcssfreq; 02056 wf.datalen = strlen(o->rxctcssfreq) + 1; 02057 TRACEO(1,("AST_CONTROL_RADIO_KEY text=%s\n",o->rxctcssfreq)); 02058 } 02059 ast_queue_frame(o->owner, &wf); 02060 } 02061 02062 o->readpos = AST_FRIENDLY_OFFSET; /* reset read pointer for next frame */ 02063 if (c->_state != AST_STATE_UP) /* drop data if frame is not up */ 02064 return f; 02065 /* ok we can build and deliver the frame to the caller */ 02066 f->frametype = AST_FRAME_VOICE; 02067 f->subclass.codec = AST_FORMAT_SLINEAR; 02068 f->samples = FRAME_SIZE; 02069 f->datalen = FRAME_SIZE * 2; 02070 f->data.ptr = o->usbradio_read_buf_8k + AST_FRIENDLY_OFFSET; 02071 if (o->boost != BOOST_SCALE) { /* scale and clip values */ 02072 int i, x; 02073 int16_t *p = (int16_t *) f->data.ptr; 02074 for (i = 0; i < f->samples; i++) { 02075 x = (p[i] * o->boost) / BOOST_SCALE; 02076 if (x > 32767) 02077 x = 32767; 02078 else if (x < -32768) 02079 x = -32768; 02080 p[i] = x; 02081 } 02082 } 02083 02084 f->offset = AST_FRIENDLY_OFFSET; 02085 if (o->dsp) 02086 { 02087 f1 = ast_dsp_process(c,o->dsp,f); 02088 if ((f1->frametype == AST_FRAME_DTMF_END) || 02089 (f1->frametype == AST_FRAME_DTMF_BEGIN)) 02090 { 02091 if ((f1->subclass.integer == 'm') || (f1->subclass.integer == 'u')) 02092 { 02093 f1->frametype = AST_FRAME_NULL; 02094 f1->subclass.integer = 0; 02095 return(f1); 02096 } 02097 if (f1->frametype == AST_FRAME_DTMF_END) 02098 ast_log(LOG_NOTICE, "Got DTMF char %c\n", f1->subclass.integer); 02099 return(f1); 02100 } 02101 } 02102 return f; 02103 }
static struct ast_channel * usbradio_request | ( | const char * | type, | |
format_t | format, | |||
const struct ast_channel * | requestor, | |||
void * | data, | |||
int * | cause | |||
) | [static] |
Definition at line 2220 of file chan_usbradio.c.
References AST_CAUSE_BUSY, AST_FORMAT_SLINEAR, ast_log(), AST_STATE_DOWN, chan_usbradio_pvt::b, find_desc(), ast_channel::linkedid, LOG_NOTICE, LOG_WARNING, chan_usbradio_pvt::owner, chan_usbradio_pvt::remoted, usbradio_new(), and xpmr_config().
02221 { 02222 struct ast_channel *c; 02223 struct chan_usbradio_pvt *o = find_desc(data); 02224 02225 TRACEO(1,("usbradio_request()\n")); 02226 02227 if (0) 02228 { 02229 ast_log(LOG_WARNING, "usbradio_request type <%s> data 0x%p <%s>\n", type, data, (char *) data); 02230 } 02231 if (o == NULL) { 02232 ast_log(LOG_NOTICE, "Device %s not found\n", (char *) data); 02233 /* XXX we could default to 'dsp' perhaps ? */ 02234 return NULL; 02235 } 02236 if ((format & AST_FORMAT_SLINEAR) == 0) { 02237 ast_log(LOG_NOTICE, "Format 0x%" PRIx64 " unsupported\n", format); 02238 return NULL; 02239 } 02240 if (o->owner) { 02241 ast_log(LOG_NOTICE, "Already have a call (chan %p) on the usb channel\n", o->owner); 02242 *cause = AST_CAUSE_BUSY; 02243 return NULL; 02244 } 02245 c = usbradio_new(o, NULL, NULL, AST_STATE_DOWN, requestor ? requestor->linkedid : NULL); 02246 if (c == NULL) { 02247 ast_log(LOG_WARNING, "Unable to create new usb channel\n"); 02248 return NULL; 02249 } 02250 02251 o->b.remoted=0; 02252 xpmr_config(o); 02253 02254 return c; 02255 }
static int usbradio_text | ( | struct ast_channel * | c, | |
const char * | text | |||
) | [static] |
Definition at line 1623 of file chan_usbradio.c.
References ast_log(), ast_verbose, chan_usbradio_pvt::b, chan_usbradio_pvt::debuglevel, find_desc(), LOG_ERROR, LOG_NOTICE, chan_usbradio_pvt::pmrChan, chan_usbradio_pvt::remoted, chan_usbradio_pvt::set_rxctcssfreqs, chan_usbradio_pvt::set_rxfreq, chan_usbradio_pvt::set_txctcssfreqs, chan_usbradio_pvt::set_txfreq, usbradio_active, and xpmr_config().
01624 { 01625 struct chan_usbradio_pvt *o = find_desc(usbradio_active); 01626 double tx,rx; 01627 char cnt,rxs[16],txs[16],txpl[16],rxpl[16]; 01628 char pwr,*cmd; 01629 01630 cmd = alloca(strlen(text) + 10); 01631 01632 /* print received messages */ 01633 if(o->debuglevel)ast_verbose(" << Console Received usbradio text %s >> \n", text); 01634 01635 cnt = sscanf(text, "%300s %15s %15s %15s %15s %1c", cmd, rxs, txs, rxpl, txpl, &pwr); 01636 01637 if (strcmp(cmd,"SETCHAN")==0) 01638 { 01639 u8 chan; 01640 chan=strtod(rxs,NULL); 01641 ppbinout(chan); 01642 if(o->debuglevel)ast_log(LOG_NOTICE,"parse usbradio SETCHAN cmd: %s chan: %i\n",text,chan); 01643 return 0; 01644 } 01645 01646 if (cnt < 6) 01647 { 01648 ast_log(LOG_ERROR,"Cannot parse usbradio text: %s\n",text); 01649 return 0; 01650 } 01651 else 01652 { 01653 if(o->debuglevel)ast_verbose(" << %s %s %s %s %s %c >> \n", cmd,rxs,txs,rxpl,txpl,pwr); 01654 } 01655 01656 if (strcmp(cmd,"SETFREQ")==0) 01657 { 01658 if(o->debuglevel)ast_log(LOG_NOTICE,"parse usbradio SETFREQ cmd: %s\n",text); 01659 tx=strtod(txs,NULL); 01660 rx=strtod(rxs,NULL); 01661 o->set_txfreq = round(tx * (double)1000000); 01662 o->set_rxfreq = round(rx * (double)1000000); 01663 o->pmrChan->txpower = (pwr == 'H'); 01664 strcpy(o->set_rxctcssfreqs,rxpl); 01665 strcpy(o->set_txctcssfreqs,txpl); 01666 01667 o->b.remoted=1; 01668 xpmr_config(o); 01669 return 0; 01670 } 01671 ast_log(LOG_ERROR,"Cannot parse usbradio cmd: %s\n",text); 01672 return 0; 01673 }
static int usbradio_write | ( | struct ast_channel * | chan, | |
struct ast_frame * | f | |||
) | [static] |
Definition at line 1743 of file chan_usbradio.c.
References ast_log(), chan_usbradio_pvt::b, errno, f, ftxcapraw, LOG_ERROR, ast_channel::tech_pvt, traceusb2, chan_usbradio_pvt::txcapraw, and chan_usbradio_pvt::txkeyed.
01744 { 01745 struct chan_usbradio_pvt *o = c->tech_pvt; 01746 01747 traceusb2(("usbradio_write() o->nosound= %i\n",o->nosound)); 01748 01749 #ifndef NEW_ASTERISK 01750 /* Immediately return if no sound is enabled */ 01751 if (o->nosound) 01752 return 0; 01753 /* Stop any currently playing sound */ 01754 o->cursound = -1; 01755 #endif 01756 /* 01757 * we could receive a block which is not a multiple of our 01758 * FRAME_SIZE, so buffer it locally and write to the device 01759 * in FRAME_SIZE chunks. 01760 * Keep the residue stored for future use. 01761 */ 01762 01763 #if DEBUG_CAPTURES == 1 // to write input data to a file datalen=320 01764 if (ftxcapraw && o->b.txcapraw) 01765 { 01766 i16 i, tbuff[f->datalen]; 01767 for(i=0;i<f->datalen;i+=2) 01768 { 01769 tbuff[i]= ((i16*)(f->data.ptr))[i/2]; 01770 tbuff[i+1]= o->txkeyed*M_Q13; 01771 } 01772 if (fwrite(tbuff,2,f->datalen,ftxcapraw) != f->datalen) { 01773 ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno)); 01774 } 01775 //fwrite(f->data,1,f->datalen,ftxcapraw); 01776 } 01777 #endif 01778 01779 // maw just take the data from the network and save it for PmrRx processing 01780 01781 PmrTx(o->pmrChan,(i16*)f->data.ptr); 01782 01783 return 0; 01784 }
static int used_blocks | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 1322 of file chan_usbradio.c.
References ast_log(), LOG_WARNING, chan_usbradio_pvt::sounddev, chan_usbradio_pvt::total_blocks, WARN_used_blocks, and chan_usbradio_pvt::warned.
01323 { 01324 struct audio_buf_info info; 01325 01326 if (ioctl(o->sounddev, SNDCTL_DSP_GETOSPACE, &info)) { 01327 if (!(o->warned & WARN_used_blocks)) { 01328 ast_log(LOG_WARNING, "Error reading output space\n"); 01329 o->warned |= WARN_used_blocks; 01330 } 01331 return 1; 01332 } 01333 01334 if (o->total_blocks == 0) { 01335 if (0) /* debugging */ 01336 ast_log(LOG_WARNING, "fragtotal %d size %d avail %d\n", info.fragstotal, info.fragsize, info.fragments); 01337 o->total_blocks = info.fragments; 01338 } 01339 01340 return o->total_blocks - info.fragments; 01341 }
static void write_eeprom | ( | struct usb_dev_handle * | handle, | |
int | addr, | |||
unsigned short | data | |||
) | [static] |
Definition at line 840 of file chan_usbradio.c.
References hid_set_outputs().
Referenced by put_eeprom().
00842 { 00843 00844 unsigned char buf[4]; 00845 00846 buf[0] = 0x80; 00847 buf[1] = data & 0xff; 00848 buf[2] = data >> 8; 00849 buf[3] = 0xc0 | (addr & 0x3f); 00850 hid_set_outputs(handle,buf); 00851 }
static int xpmr_config | ( | struct chan_usbradio_pvt * | o | ) | [static] |
Definition at line 3354 of file chan_usbradio.c.
References ast_log(), chan_usbradio_pvt::b, LOG_ERROR, chan_usbradio_pvt::pmrChan, chan_usbradio_pvt::remoted, chan_usbradio_pvt::rxctcssfreqs, chan_usbradio_pvt::rxctcssrelax, chan_usbradio_pvt::rxfreq, chan_usbradio_pvt::set_rxctcssfreqs, chan_usbradio_pvt::set_rxfreq, chan_usbradio_pvt::set_txctcssdefault, chan_usbradio_pvt::set_txctcssfreqs, chan_usbradio_pvt::set_txfreq, chan_usbradio_pvt::txctcssdefault, chan_usbradio_pvt::txctcssfreqs, and chan_usbradio_pvt::txfreq.
Referenced by store_config(), usbradio_request(), and usbradio_text().
03355 { 03356 //ast_log(LOG_NOTICE,"xpmr_config()\n"); 03357 03358 TRACEO(1,("xpmr_config()\n")); 03359 03360 if(o->pmrChan==NULL) 03361 { 03362 ast_log(LOG_ERROR,"pmr channel structure NULL\n"); 03363 return 1; 03364 } 03365 03366 o->pmrChan->rxCtcss->relax = o->rxctcssrelax; 03367 o->pmrChan->txpower=0; 03368 03369 if(o->b.remoted) 03370 { 03371 o->pmrChan->pTxCodeDefault = o->set_txctcssdefault; 03372 o->pmrChan->pRxCodeSrc=o->set_rxctcssfreqs; 03373 o->pmrChan->pTxCodeSrc=o->set_txctcssfreqs; 03374 03375 o->pmrChan->rxfreq=o->set_rxfreq; 03376 o->pmrChan->txfreq=o->set_txfreq; 03377 /* printf(" remoted %s %s --> %s \n",o->pmrChan->txctcssdefault, 03378 o->pmrChan->txctcssfreq,o->pmrChan->rxctcssfreq); */ 03379 } 03380 else 03381 { 03382 // set xpmr pointers to source strings 03383 03384 o->pmrChan->pTxCodeDefault = o->txctcssdefault; 03385 o->pmrChan->pRxCodeSrc = o->rxctcssfreqs; 03386 o->pmrChan->pTxCodeSrc = o->txctcssfreqs; 03387 03388 o->pmrChan->rxfreq = o->rxfreq; 03389 o->pmrChan->txfreq = o->txfreq; 03390 } 03391 03392 code_string_parse(o->pmrChan); 03393 if(o->pmrChan->rxfreq) o->pmrChan->b.reprog=1; 03394 03395 return 0; 03396 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "usb Console Channel Driver" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 4028 of file chan_usbradio.c.
char active_usage[] [static] |
Initial value:
"Usage: radio active [device-name]\n" " If used without a parameter, displays which device is the current\n" "one being commanded. If a device is specified, the commanded radio device is changed\n" "to the device specified.\n"
Definition at line 2626 of file chan_usbradio.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 4028 of file chan_usbradio.c.
struct ast_cli_entry cli_usbradio[] [static] |
const char* config = "usbradio.conf" [static] |
Definition at line 360 of file chan_usbradio.c.
struct ast_jb_conf default_jbconf [static] |
Global jitterbuffer configuration - by default, jb is disabled
Definition at line 195 of file chan_usbradio.c.
FILE* frxcapraw = NULL [static] |
Definition at line 363 of file chan_usbradio.c.
Referenced by radio_tune(), unload_module(), and usbradio_read().
FILE * frxcaptrace = NULL [static] |
Definition at line 363 of file chan_usbradio.c.
Referenced by radio_tune(), unload_module(), and usbradio_read().
FILE * frxoutraw = NULL [static] |
Definition at line 363 of file chan_usbradio.c.
Referenced by radio_tune(), unload_module(), and usbradio_read().
FILE* ftxcapraw = NULL [static] |
Definition at line 364 of file chan_usbradio.c.
Referenced by radio_tune(), unload_module(), and usbradio_write().
FILE * ftxcaptrace = NULL [static] |
Definition at line 364 of file chan_usbradio.c.
Referenced by radio_tune(), unload_module(), and usbradio_read().
FILE * ftxoutraw = NULL [static] |
Definition at line 364 of file chan_usbradio.c.
Referenced by radio_tune(), unload_module(), and usbradio_read().
struct ast_jb_conf global_jbconf [static] |
Definition at line 203 of file chan_usbradio.c.
char key_usage[] [static] |
Initial value:
"Usage: radio key\n" " Simulates COR active.\n"
Definition at line 2618 of file chan_usbradio.c.
char radio_tune_usage[] [static] |
Definition at line 2634 of file chan_usbradio.c.
char tdesc[] = "USB (CM108) Radio Channel Driver" [static] |
Definition at line 687 of file chan_usbradio.c.
char unkey_usage[] [static] |
Initial value:
"Usage: radio unkey\n" " Simulates COR un-active.\n"
Definition at line 2622 of file chan_usbradio.c.
char* usb_device_list = NULL [static] |
int usb_device_list_size = 0 [static] |
Definition at line 367 of file chan_usbradio.c.
char* usbradio_active [static] |
Definition at line 664 of file chan_usbradio.c.
Referenced by console_key(), console_unkey(), load_module(), radio_active(), radio_set_debug(), radio_set_debug_off(), radio_set_xpmr_debug(), radio_tune(), store_config(), and usbradio_text().
int usbradio_debug [static] |
Definition at line 369 of file chan_usbradio.c.
Referenced by soundcard_writeframe(), and store_config().
struct chan_usbradio_pvt usbradio_default [static] |
Definition at line 629 of file chan_usbradio.c.
Referenced by find_desc(), find_desc_usb(), radio_active(), store_config(), and unload_module().
struct ast_channel_tech usbradio_tech [static] |
Definition at line 689 of file chan_usbradio.c.
Referenced by load_module(), unload_module(), usbradio_new(), and usbradio_read().