void printButtons (ButtonResourceType *buttons) { while (buttons->name != NULL) { printf ("Button %s (port:%s, bit:%d)\r\n", buttons->name, PORT_NAME(buttons->gpioPort), buttons->gpioPin); buttons++; } }
void boardPrintStringDescription(void) { int8u i = 0; while (boardList[i] != NULL) { if ((boardDescription == boardList[i]) || (boardDescription == NULL)) { BoardResourcesType *ptr = boardList[i]; printf ("*************************************\r\n"); printf ("Board name = %s\r\n", ptr->name); printf ("*************************************\r\n"); printLeds(ptr->leds); printButtons(ptr->buttons); if (ptr->mems) { printf ("MEMS = %s\r\n", ptr->mems->name); } if (ptr->temperatureSensor) { printf ("Temp sensor = %s, port:%s, pin:%d, adcFix:%s\r\n", ptr->temperatureSensor->name, PORT_NAME(ptr->temperatureSensor->gpioPort), ptr->temperatureSensor->gpioPin, ptr->temperatureSensor->adcFix ? "Yes" : "No" ); } printf ("EEProm:%s\r\n", ptr->EEProm ? "Yes" : "No"); printf ("PC i/f:%s\r\n", ptr->FTDInotSTM32 ? "FTDI" : "STM32F"); printf ("Power Amplifier:%s\r\n", ptr->PowerAmplifier ? "Yes" : "No"); } i++; } return NULL; }
void printLeds (LedResourceType *leds) { while (leds->name != NULL) { printf ("Led %s (port:%s, bit:%d)\r\n", leds->name, PORT_NAME(leds->gpioPort), leds->gpioPin); leds++; } }
static int es705_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { unsigned int base = dai->driver->base; unsigned int msg, resp; int ret, val; u32 cmd_block[3]; return 0; if (escore_priv.flag.is_fw_ready == 0) { pr_warn("%s(port-%c): es705 firmware is not ready, abort\n", __func__, PORT_NAME(base)); return 0; } /* word length */ //if (es705_ports[PORT_ID(base)].wl != params_format(params)) { printk("++%s(port-%c)++: format=%d\n", __func__, PORT_NAME(base), params_format(params)); val = snd_pcm_format_width(params_format(params)) - 1; cmd_block[0] = ES705_PORT_PARAM_ID + base + ES705_PORT_WORDLENGHT; cmd_block[1] = ES705_PORT_SET_PARAM + val; cmd_block[2] = 0xffffffff; ret = escore_write_block(&escore_priv, cmd_block); if (ret < 0) { dev_err(dai->dev, "escore_cmd: send [%08x %08x] failed\n", cmd_block[0], cmd_block[2]); goto out; } es705_ports[PORT_ID(base)].wl = params_format(params); } /* sample rate */ //if (es705_ports[PORT_ID(base)].rate != params_rate(params)) { printk("++%s(port-%c)++: rate=%d\n", __func__, PORT_NAME(base), params_rate(params)); msg = ES705_PORT_GET_PARAM + base + ES705_PORT_CLOCK; ret = escore_cmd(&escore_priv, msg, &resp); if (ret < 0) { dev_err(dai->dev, "escore_cmd: send %08x failed\n", msg); goto out; } val = (resp & 0x100) + (params_rate(params) / 1000); cmd_block[0] = ES705_PORT_PARAM_ID + base + ES705_PORT_CLOCK; cmd_block[1] = ES705_PORT_SET_PARAM + val; cmd_block[2] = 0xffffffff; ret = escore_write_block(&escore_priv, cmd_block); if (ret < 0) { dev_err(dai->dev, "escore_cmd: send [%08x %08x] failed\n", cmd_block[0], cmd_block[2]); goto out; } es705_ports[PORT_ID(base)].rate = params_rate(params); } out: return ret; }
static int es705_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { unsigned int base = dai->driver->base; unsigned int msg, resp; int ret = 0, val; u32 cmd_block[3]; return 0; if (escore_priv.flag.is_fw_ready == 0) { pr_warn("%s(): es705 firmware is not ready, abort\n", __func__); return 0; } //if (es705_ports[PORT_ID(base)].fmt == fmt) // return 0; /* port mode */ if (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { printk("++%s(port-%c)++: port-mode=%s\n", __func__, PORT_NAME(base), (fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S ? "i2s" : "pcm"); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_DSP_A: val = 0x00; break; case SND_SOC_DAIFMT_I2S: val = 0x01; break; default: dev_err(dai->dev, "Unsupported DAI format %d\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK); ret = -EINVAL; goto out; } cmd_block[0] = ES705_PORT_PARAM_ID + base + ES705_PORT_MODE; cmd_block[1] = ES705_PORT_SET_PARAM + val; cmd_block[2] = 0xffffffff; ret = escore_write_block(&escore_priv, cmd_block); if (ret < 0) { dev_err(dai->dev, "escore_cmd: send [%08x %08x] failed\n", cmd_block[0], cmd_block[2]); goto out; } /* latch edge: Tx on Falling Edge, Rx on Rising Edge */ if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_DSP_A) { cmd_block[0] = ES705_PORT_PARAM_ID + base + ES705_PORT_LATCHEDGE; cmd_block[1] = ES705_PORT_SET_PARAM + 0x01; cmd_block[2] = 0xffffffff; ret = escore_write_block(&escore_priv, cmd_block); if (ret < 0) { dev_err(dai->dev, "escore_cmd: send [%08x %08x] failed\n", cmd_block[0], cmd_block[2]); goto out; } } } /* master mode */ if (fmt & SND_SOC_DAIFMT_MASTER_MASK) { printk("++%s(port-%c)++: clock-mode=%s\n", __func__, PORT_NAME(base), (fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBS_CFS ? "slave" : "master"); msg = ES705_PORT_GET_PARAM + base + ES705_PORT_CLOCK; ret = escore_cmd(&escore_priv, msg, &resp); if (ret < 0) { dev_err(dai->dev, "escore_cmd: send %08x failed\n", msg); goto out; } switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: val = resp & 0xff; // slave: bit8 = 0 break; case SND_SOC_DAIFMT_CBM_CFM: val = (resp & 0xff) | 0x100; // master: bit8 = 1 break; default: dev_err(dai->dev, "Unsupported master mode %d\n", fmt & SND_SOC_DAIFMT_MASTER_MASK); ret = -EINVAL; goto out; } cmd_block[0] = ES705_PORT_PARAM_ID + base + ES705_PORT_CLOCK; cmd_block[1] = ES705_PORT_SET_PARAM + val; cmd_block[2] = 0xffffffff; ret = escore_write_block(&escore_priv, cmd_block); if (ret < 0) { dev_err(dai->dev, "escore_cmd: send [%08x %08x] failed\n", cmd_block[0], cmd_block[2]); goto out; } } es705_ports[PORT_ID(base)].fmt = fmt; out: return ret; }