socsvn commit: r290037 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner

pratiksinghal at FreeBSD.org pratiksinghal at FreeBSD.org
Fri Aug 21 17:35:38 UTC 2015


Author: pratiksinghal
Date: Fri Aug 21 17:35:37 2015
New Revision: 290037
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=290037

Log:
  Implemented trigger and blocksize functions

Modified:
  soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c

Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c
==============================================================================
--- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c	Fri Aug 21 16:05:56 2015	(r290036)
+++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_ac97.c	Fri Aug 21 17:35:37 2015	(r290037)
@@ -50,6 +50,8 @@
 	struct snd_dbuf* buf;
 	struct pcm_channel* channel;
 	struct a10_ac97_info* parent;
+	uint32_t blksize;
+	uint32_t blkcount;
 	uint32_t flags;
 	uint32_t fmt;
 	int		 type;
@@ -80,10 +82,14 @@
 static int ac97_detach(device_t);
 static void *a10_ac97_chan_init(kobj_t, void *, struct snd_dbuf *, struct pcm_channel *, int);
 static int a10_ac97_setfmt(kobj_t, void *, uint32_t);
+static uint32_t a10_ac97_setblocksize(kobj_t, void *, uint32_t);
+static int a10_ac97_trigger(kobj_t, void *, int);
 
 static kobj_method_t a10_ac97_chan_methods[] = {
 	KOBJMETHOD(channel_init, a10_ac97_chan_init),
 	KOBJMETHOD(channel_setformat, a10_ac97_setfmt),
+	KOBJMETHOD(channel_setblocksize, a10_ac97_setblocksize),
+	KOBJMETHOD(channel_trigger, a10_ac97_trigger),
 	KOBJMETHOD_END
 };	
 
@@ -113,7 +119,8 @@
  *  Enable Codec Ready interrupt
  */
 
-static int ac97_attach(device_t dev)
+static int 
+ac97_attach(device_t dev)
 {
 	struct a10_ac97_info *sc;
 	int error;
@@ -189,12 +196,14 @@
 	return (ENXIO);
 }
 
-static int ac97_detach(device_t dev)
+static int 
+ac97_detach(device_t dev)
 {
 	return (EBUSY);
 }
 
-static void * a10_ac97_chan_init(kobj_t kobj, void *devinfo, struct snd_dbuf *b,
+static void * 
+a10_ac97_chan_init(kobj_t kobj, void *devinfo, struct snd_dbuf *b,
 									struct pcm_channel *c, int type)
 {
 	struct a10_ac97_info* sc = (struct a10_ac97_info*) devinfo;
@@ -216,7 +225,8 @@
 	return (ch);
 }
 
-static int a10_ac97_setfmt(kobj_t obj, void *chn, uint32_t fmt)
+static int 
+a10_ac97_setfmt(kobj_t obj, void *chn, uint32_t fmt)
 {
 	struct a10_ac97_channel *channel = (struct a10_ac97_channel *)chn;
 	struct a10_ac97_info *sc = channel->parent;
@@ -243,6 +253,37 @@
 	}
 }
 
+static uint32_t
+a10_ac97_setblocksize(kobj_t obj, void *data, uint32_t blksize)
+{
+	struct a10_ac97_channel *ch = (struct a10_ac97_channel *) data;
+	ch->blksize = blksize;
+	
+	return (0);
+}
+
+static int
+a10_ac97_trigger(kobj_t obj, void *data, int go)
+{
+	struct a10_ac97_channel *ch = (struct a10_ac97_channel *)data;
+	struct a10_ac97_info *sc = ch->parent;
+	uint32_t total = sndbuf_getsize(ch->buf) >> 2;
+	uint32_t i=0;
+	uint32_t* buf = (uint32_t *) sndbuf_getbuf(ch->buf);
+
+	if (go == PCMTRIG_START) {
+		if (ch->type == PCMDIR_PLAY) {
+			for (; i < total; i++)
+				AC97_WRITE(sc,AC_TX_FIFO,buf[i]);
+		}
+		else
+			for (; i < total; i++)
+				buf[i] = AC97_READ(sc, AC_RX_FIFO);
+	}
+	return (0);
+		
+}
+
 static device_method_t a10_ac97_methods[] = { 
 	DEVMETHOD(device_probe, 		ac97_probe),
 	DEVMETHOD(device_attach,		ac97_attach),


More information about the svn-soc-all mailing list