Skip to content

Commit

Permalink
Merge pull request embox#1066 from embox/pjsip-improve
Browse files Browse the repository at this point in the history
Pjsip improve
  • Loading branch information
Deryugin authored Apr 1, 2017
2 parents 81dff35 + a418bf9 commit f844092
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 168 deletions.
12 changes: 10 additions & 2 deletions platform/pjsip/templates/arm-qemu/mods.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ configuration conf {
@Runlevel(2) include embox.mem.static_heap(heap_size=0x1000000)

@Runlevel(0) include embox.mem.mmap_mmu
@Runlevel(0) include embox.mem.vmem
@Runlevel(0) include embox.mem.vmem_alloc(pgd_align=0x4000,pmd_align=0x1000,pte_align=0x1000)
@Runlevel(0) include embox.kernel.critical

Expand All @@ -25,7 +26,8 @@ configuration conf {
@Runlevel(2) include embox.driver.serial.pl011(base_addr=0x10009000, irq_num=37, baud_rate=115200) /* irq_num 5+32 */
@Runlevel(1) include embox.driver.diag(impl="embox__driver__serial__pl011")
@Runlevel(0) include embox.driver.clock.cortexa9(periph_base_addr=0x1e000000,irq_num=29)
//@Runlevel(1) include embox.driver.net.lan9118
@Runlevel(1) include embox.driver.net.lan9118
@Runlevel(1) include embox.driver.net.lan9118_non_gpio_irq(base_address=0x4E000000,irq_nr=47,memory_region_size = 0x1000000)
@Runlevel(2) include embox.driver.net.loopback

include embox.compat.libc.stdio.print(support_floating=0)
Expand All @@ -50,7 +52,8 @@ configuration conf {
//@Runlevel(3) include embox.init.start_script
//@Runlevel(2) include embox.cmd.shell
@Runlevel(2) include embox.cmd.sh.tish(prompt="embox#")
@Runlevel(3) include embox.init.start_script(shell_name="tish", shell_start=1, stop_on_error=true)
//@Runlevel(3) include embox.init.start_script(shell_name="tish", shell_start=1, stop_on_error=true)
include embox.init.system_start_service
include embox.cmd.service

include embox.cmd.net.arp
Expand Down Expand Up @@ -85,6 +88,9 @@ configuration conf {
include embox.cmd.fs.cat
include embox.cmd.fs.ls

include embox.cmd.proc.thread
include embox.cmd.proc.top

@Runlevel(2) include embox.net.core
@Runlevel(2) include embox.net.skbuff(amount_skb=4000)
@Runlevel(2) include embox.net.skbuff_data(amount_skb_data=4000,data_size=1514,data_align=1,data_padto=1,ip_align=false)
Expand All @@ -105,5 +111,7 @@ configuration conf {

@Runlevel(2) include embox.driver.audio.aaci_pl041(log_level=1, base_addr=0x10004000, irq_num=43) /* irq 11+32 */
include third_party.pjproject.pjsua
include third_party.pjproject.simpleua
include embox.cmd.play
include embox.cmd.record
}
9 changes: 9 additions & 0 deletions platform/pjsip/templates/arm-qemu/rootfs/network
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
iface eth0 inet static
address 10.0.2.16
netmask 255.255.255.0
gateway 10.0.2.10
hwaddress aa:bb:cc:dd:ee:02

iface lo inet static
address 127.0.0.1
netmask 255.0.0.0
5 changes: 0 additions & 5 deletions platform/pjsip/templates/arm-qemu/start_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
"ifconfig lo 127.0.0.1 netmask 255.0.0.0 up",
"route add 127.0.0.0 netmask 255.0.0.0 lo",
/* Setup eth0 interface */
/*
"ifconfig eth0 10.0.2.16 netmask 255.255.255.0 hw ether AA:BB:CC:DD:EE:02 up",
"route add 10.0.2.0 netmask 255.255.255.0 eth0",
"route add default gw 10.0.2.10 eth0",
*/
/* Env variables */
"export PWD=/",
"export HOME=/",
6 changes: 5 additions & 1 deletion platform/pjsip/templates/arm-qemu/system_start.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"export PWD=/",
"export HOME=/",
"netmanager",
"service telnetd",
"service httpd",
"tish",
/* Run simpleua */
"service pjsip_simpleua",
"tish",
12 changes: 10 additions & 2 deletions platform/pjsip/templates/x86-qemu/mods.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ configuration conf {
include embox.arch.x86.mmu
@Runlevel(2) include embox.test.mmu_core

include embox.arch.x86.vfork

include embox.arch.x86.libarch

include embox.arch.x86.stackframe
Expand Down Expand Up @@ -39,6 +41,7 @@ configuration conf {

include embox.driver.ramdisk(size=130008864,ramdisk_quantity=2)
include embox.cmd.fs.mkramdisk
include embox.cmd.net.netmanager


@Runlevel(1) include embox.kernel.timer.sys_timer
Expand Down Expand Up @@ -86,7 +89,10 @@ configuration conf {
@Runlevel(1) include embox.test.util.hashtable_test

@Runlevel(2) include embox.cmd.sh.tish(prompt="%u@%h:%w%$", rich_prompt_support=1, builtin_commands="exit logout cd export mount umount")
@Runlevel(3) include embox.init.start_script(shell_name="tish", tty_dev="ttyS0", shell_start=1, stop_on_error=true)
//@Runlevel(3) include embox.init.start_script(shell_name="tish", tty_dev="ttyS0", shell_start=1, stop_on_error=true)
include embox.init.system_start_service

include embox.cmd.service
include embox.cmd.net.arp
include embox.cmd.net.netstat
include embox.cmd.net.arping
Expand Down Expand Up @@ -171,7 +177,9 @@ configuration conf {
@Runlevel(2) include embox.framework.LibFramework
@Runlevel(2) include embox.compat.libc.all

//include third_party.pjproject.pjsua
include third_party.pjproject.pjsua
include third_party.pjproject.simpleua

//include embox.driver.audio.es1370
include embox.driver.audio.intel_ac_pa(log_level=4)
include embox.driver.audio.portaudio_lib(log_level=4)
Expand Down
9 changes: 9 additions & 0 deletions platform/pjsip/templates/x86-qemu/rootfs/network
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
iface eth0 inet static
address 10.0.2.16
netmask 255.255.255.0
gateway 10.0.2.10
hwaddress aa:bb:cc:dd:ee:02

iface lo inet static
address 127.0.0.1
netmask 255.0.0.0
16 changes: 3 additions & 13 deletions platform/pjsip/templates/x86-qemu/start_script.inc
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
//"mkdir mnt",
"mount -t ramfs /dev/ram0 /mnt"
//"record file.wav"
#if 0
/* Setup loopback interface */
"ifconfig lo 127.0.0.1 netmask 255.0.0.0 up",
"route add 127.0.0.0 netmask 255.0.0.0 lo",
/* Setup eth0 interface */
"ifconfig eth0 10.0.2.16 netmask 255.255.255.0 hw ether AA:BB:CC:DD:EE:02 up",
"route add 10.0.2.0 netmask 255.255.255.0 eth0",
"route add default gw 10.0.2.10 eth0",
"netmanager",

"export PWD=/",
"export HOME=/",
#endif
/* Run simpleua */
"pjsip_simpleua"
8 changes: 8 additions & 0 deletions platform/pjsip/templates/x86-qemu/system_start.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"export PWD=/",
"export HOME=/",
"netmanager",
"service telnetd",
"service httpd",
/* Run simpleua */
"service pjsip_simpleua",
"tish",
3 changes: 2 additions & 1 deletion src/drivers/audio/aaci_pl041/Mybuild
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ module aaci_pl041 {

depends embox.driver.audio.portaudio_lib
depends embox.driver.audio.audio_dev
}
depends embox.driver.audio.ac97
}
80 changes: 14 additions & 66 deletions src/drivers/audio/aaci_pl041/aaci_pl041.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ EMBOX_UNIT_INIT(aaci_pl041_init);
#define IRQ_NUM OPTION_GET(NUMBER, irq_num)

#define AACI_MAXBUF_LEN_MAX_BUF_LEN 0x10000

#define FIFO_SAMPLE_SZ 4 /* 32 bits */
#define FRAME_PERIOD_US 50

struct aaci_runtime {
Expand All @@ -49,7 +49,6 @@ struct aaci_pl041_hw_dev {

static struct aaci_pl041_hw_dev aaci_pl041_hw_dev;


struct aaci_pl041_dev_priv {
struct aaci_pl041_hw_dev *hw_dev;
int devid;
Expand Down Expand Up @@ -154,11 +153,13 @@ static void aaci_pl041_dev_resume(struct audio_dev *dev) {
static int aaci_pl041_ioctl(struct audio_dev *dev, int cmd, void *args) {
log_debug("dev = 0x%X", dev);
switch(cmd) {
case ADIOCTL_IN_SUPPORT:
return 0;
case ADIOCTL_OUT_SUPPORT:
return AD_STEREO_SUPPORT |
AD_16BIT_SUPPORT;
case ADIOCTL_BUFLEN:
return aaci_pl041_hw_dev.fifo_depth;
return aaci_pl041_hw_dev.fifo_depth * FIFO_SAMPLE_SZ;
}
SET_ERRNO(EINVAL);
return -1;
Expand Down Expand Up @@ -206,6 +207,9 @@ uint8_t *audio_dev_get_out_cur_ptr(struct audio_dev *audio_dev) {
return priv->out_buf;
}

uint8_t *audio_dev_get_in_cur_ptr(struct audio_dev *audio_dev) {
return NULL;
}

static void aaci_ac97_select_codec(struct aaci_pl041_hw_dev *hw_dev) {
uint32_t v;
Expand All @@ -227,11 +231,11 @@ static void aaci_ac97_select_codec(struct aaci_pl041_hw_dev *hw_dev) {
}
}

static void aaci_ac97_write(struct aaci_pl041_hw_dev *hw_dev, unsigned short reg,
unsigned short val) {
void ac97_reg_write(unsigned short reg, unsigned short val) {
int timeout;
uint32_t v;

struct aaci_pl041_hw_dev *hw_dev = &aaci_pl041_hw_dev;
aaci_ac97_select_codec(hw_dev);

/*
Expand All @@ -255,10 +259,10 @@ static void aaci_ac97_write(struct aaci_pl041_hw_dev *hw_dev, unsigned short reg
log_error("timeout waiting for write to complete\n");
}

static unsigned short aaci_ac97_read(struct aaci_pl041_hw_dev *hw_dev, unsigned short reg) {
uint16_t ac97_reg_read(unsigned short reg) {
int timeout, retries = 10;
uint32_t v;

struct aaci_pl041_hw_dev *hw_dev = &aaci_pl041_hw_dev;

aaci_ac97_select_codec(hw_dev);

Expand Down Expand Up @@ -313,7 +317,7 @@ static unsigned short aaci_ac97_read(struct aaci_pl041_hw_dev *hw_dev, unsigned
v = ~0;
}
} while (retries);
out:
out:
return v;
}

Expand Down Expand Up @@ -392,7 +396,7 @@ static void aaci_fifo_irq(uint32_t base, int channel, uint32_t mask) {
REG32_STORE(base + AACI_INTCLR, AACI_ICLR_TXUEC1 << channel);
}

if (mask & AACI_ISR_TXINTR) {
if (mask & AACI_ISR_TXCINTR) {
/*
AACITXINTR 1-4
If the FIFO is enabled, the FIFO transmit interrupt is asserted
Expand All @@ -414,8 +418,6 @@ static void aaci_fifo_irq(uint32_t base, int channel, uint32_t mask) {
}
}



static irq_return_t aaci_pl041_irq_handler(unsigned int irq_num, void *dev_id) {
uint32_t mask;
int i;
Expand All @@ -437,60 +439,6 @@ static irq_return_t aaci_pl041_irq_handler(unsigned int irq_num, void *dev_id) {
return mask ? IRQ_HANDLED : IRQ_NONE;
}

/********************************************
* AC'97
********************************************/
int ac97_reset(void) {
/* Actually we can write anything to
* this register to reset codec */
aaci_ac97_write(&aaci_pl041_hw_dev, AC97_RESET, 0xFFFF);

return 0;
}

/**
* @brief Changle volume settings
*
* @param vol New volume from 0x0...0x3F range
*
* @return Negative error code
*/
int ac97_set_vol(int vol) {
assert(vol <= 0x3F);
assert(vol >= 0);

aaci_ac97_write(&aaci_pl041_hw_dev, AC97_MASTER, vol);
aaci_ac97_write(&aaci_pl041_hw_dev, AC97_HEADPHONE, vol);
aaci_ac97_write(&aaci_pl041_hw_dev, AC97_MASTER_MONO, vol);

return 0;
}

/**
* @brief Get master volume value
*
* @return Master volume value from 0x0...0x3F range
*/
int ac97_get_vol(void) {
return 0x3F & aaci_ac97_read(&aaci_pl041_hw_dev, AC97_MASTER);
}

/**
* @brief Initialize codec, setup static values and so on
*
* @param pci_dev PCI device of Intel Audio Controller
* TODO handle other sound cards
*
* @return Negative error number
*/
int aaci_ac97_init(void) {
ac97_reset();
/* Set maximum master volume */
ac97_set_vol(0x3F);

return 0;
}

/**************************************************
* End of AC'97
**************************************************/
Expand Down Expand Up @@ -537,7 +485,7 @@ static int aaci_pl041_init(void) {
*/
aaci_pl041_hw_dev.fifo_depth = aaci_size_fifo(&aaci_pl041_hw_dev);

if ((ret = aaci_ac97_init())) {
if ((ret = ac97_init())) {
return ret;
}

Expand Down
3 changes: 0 additions & 3 deletions src/drivers/audio/ac97/Mybuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ module ac97 {
source "ac97.h"

source "ac97.c"

depends embox.arch.x86.kernel.arch
depends embox.driver.pci
}
Loading

0 comments on commit f844092

Please sign in to comment.