Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Gaming / Games / Multimedia / Entertainment
Reload this Page codec driver developement problems
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Gaming / Games / Multimedia / Entertainment General discussion about Games, video, sound, multimedia, DVD's in Linux

Reply
 
Thread Tools Display Modes
Old 05-12-2008   #1 (permalink)
umeshyv
Just Joined!
 
Join Date: Mar 2007
Posts: 30
codec driver developement problems

Hi to all,
I have few problems in writing the sound driver,the codec registers are accessed thru SPI,codec(tsc2301) is interfaced to I2S ,and SPI and I2S are in PSC controller(I2S is in PSC0 and SPI to PSC1 in Au1200 MIPS processor).Thru SPI frame the codec registers are accessed.But the hack is I could not access the SPI functions from codec driver(/sound/oss).Let me show the part the coding which I am using in codec
.
tsc2301-spi.c(/drivers/spi/)

u16 tsc2301_read_reg(struct tsc2301 *tsc, int reg)
{ struct spi_transfer t;
struct spi_message m;
u16 data[2] = {0}, cmd;
u16 dataread[2];
cmd = reg;
cmd |= 0x8000;
memset(&t, 0, sizeof(t));
spi_message_init(&m);
m.spi = tsc->spi;
dataread[0] = cmd;
dataread[1] = 0;
t.tx_buf = dataread;
t.rx_buf = &data;
t.len = 4;
spi_message_add_tail(&t, &m);
spi_sync(m.spi, &m);
return data[1];
}

void tsc2301_write_reg(struct tsc2301 *tsc, int reg, u16 val)
{ struct spi_transfer t;
struct spi_message m;
u16 data[2];
/* Now we prepare the command for transferring */
data[0] = reg;
data[1] = val;
spi_message_init(&m);
m.spi = tsc->spi;
memset(&t, 0, sizeof(t));
t.tx_buf = data;
t.rx_buf = NULL;
t.len = 4;
spi_message_add_tail(&t, &m);
spi_sync(m.spi, &m);
}

tsc2301.h(include/linux/spi)

struct tsc2301 {
struct spi_device *spi;
s16 reset_gpio;
u16 config2_shadow;
struct tsc2301_ts *ts;
int (*enable_clock)(struct device *dev);
void (*disable_clock)(struct device *dev);
};

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/ioport.h>
#include <linux/sound.h>
#include <linux/slab.h>
#include <linux/soundcard.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/hardirq.h>
#include <linux/sched.h>
#include <linux/device.h>
#include <linux/tsc2301-i2s.h>
#include <linux/spi/tsc2301.h>
#include <linux/spi/spi.h>
#include <linux/init.h>

#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/mach-au1x00/au1xxx.h>
#include <asm/mach-au1x00/au1xxx_psc.h>
#include <asm/mach-au1x00/au1550_spi.h>

#include "au1550_i2s.h"
static void tsc2301_codec_init(struct i2s_hw *hw)
{
struct spi_device *spi;
struct tsc2301 *tsc = dev_get_drvdata(&spi->dev);
//struct tsc2301 *xyz = dev_get_drvdata(&spi->dev);
int a,b;
//b = get_tsc(xyz);
//tsc2301_write_reg(b,TSC2301_REG_PD_MISC,0xFF80);
tsc2301_write_reg(tsc,TSC2301_REG_PD_MISC,0xFF80);
//tsc2301_write_reg(b,TSC2301_REG_AUDCNTL,0x0003);
a = tsc2301_read_reg(tsc,TSC2301_REG_PD_MISC);
printk("power control reg 0x%x\n",a);
//Setup some default mixer settings
hw->set_mixer(hw, SOUND_MIXER_PCM, (54<<|54);
hw->set_mixer(hw, SOUND_MIXER_MIC, (74<<|74);
hw->set_mixer(hw, SOUND_MIXER_LINE, (74<<|74);
/* Activate codec */
//tsc2301_write_reg(b,TSC2301_REG_PD_MISC,0x0040);
}
static struct i2s_hw _i2s = {
.name = "TSC2301 i2s Audio Codec",
.input_mask = SOUND_MASK_LINE | SOUND_MASK_MIC,
.output_mask = SOUND_MASK_PCM,
.codec_init = tsc2301_codec_init,
.set_rates = tsc2301_set_rates,
.get_mixer = tsc2301_read_mixer,
.set_mixer = tsc2301_write_mixer,
.set_recsrc = tsc2301_set_recsrc,
.get_recsrc = tsc2301_get_recsrc,
#ifdef CONFIG_PM
, .power = tsc2301_power,
#endif
};

struct i2s_hw * AMD_PbDb_setup(u32 psc, u32 clock)
{
volatile psc_i2s_t *ip = (volatile psc_i2s_t *)psc;
u32 val;
struct i2s_hw *i2s=&_i2s;

i2s->psc = ip;
ip->psc_ctrl = PSC_CTRL_DISABLE; /* Disable PSC */
au_sync();
/* Codec must be initialized here, after codec_is_master is determined. */
i2s->codec_init(i2s);

ip->psc_sel = (clock | PSC_SEL_PS_I2SMODE);
au_sync();

/* Enable PSC
*/
ip->psc_ctrl = PSC_CTRL_ENABLE;
au_sync();

/* Wait for PSC ready.
*/
do {
val = ip->psc_i2sstat;
printk("inside while %x",val);
au_sync();
} while ((val & PSC_I2SSTAT_SR) == 0);

/* Configure I2S controller.
* Deep FIFO, 16-bit sample, DMA, make sure DMA matches fifo size.
* Actual I2S mode (first bit delayed by one clock).
*/
val = PSC_I2SCFG_RT_FIFO8 | PSC_I2SCFG_TT_FIFO8 | PSC_I2SCFG_BI | PSC_I2SCFG_XM | PSC_I2SCFG_SET_LEN(16);
ip->psc_i2scfg = val | PSC_I2SCFG_DE_ENABLE;
au_sync();

/* Wait for device enabled */
while ((ip->psc_i2sstat & PSC_I2SSTAT_DR) == 0);
return i2s;
}
struct i2s_hw * i2s_hw_init(void)
{
/*
* Already initialized?
*/
if (!request_region(CPHYSADDR(I2S_PSC_BASE),
0x30, AU1XXX_MODULE_NAME)) {
err("I2S Audio ports in use");
return NULL;
}

return(AMD_PbDb_setup(I2S_PSC_BASE, PSC_SEL_CLK_SERCLK));
#endif

}

How could I access the tsc structure is the problem ,If the information provided is not enough I will send you as per you required.

Thanks & Regards
Umamahesh
umeshyv is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 07:39 PM.

Powered by vBulletin 3.6.8 ©2000 - 2007, content relevant URLs by vBSEO, Property of Core Root.

Content Relevant URLs by vBSEO 3.0.0