static void dw_i2s_config(struct dw_i2s_dev *dev, int stream) { u32 ch_reg; struct i2s_clk_config_data *config = &dev->config; i2s_disable_channels(dev, stream); for (ch_reg = 0; ch_reg < (config->chan_nr / 2); ch_reg++) { if (stream == SNDRV_PCM_STREAM_PLAYBACK) { i2s_write_reg(dev->i2s_base, TCR(ch_reg), dev->xfer_resolution); i2s_write_reg(dev->i2s_base, TFCR(ch_reg), dev->fifo_th - 1); i2s_write_reg(dev->i2s_base, TER(ch_reg), 1); } else { i2s_write_reg(dev->i2s_base, RCR(ch_reg), dev->xfer_resolution); i2s_write_reg(dev->i2s_base, RFCR(ch_reg), dev->fifo_th - 1); i2s_write_reg(dev->i2s_base, RER(ch_reg), 1); } } }
Rank max_in_3(T* arr, Rank p, Rank end) { Rank l = LCR(p), r = RCR(p); if (r < end) { return arr[p] >= arr[l] ? (arr[p] >= arr[r] ? p : r) : (arr[l] >= arr[r] ? l : r); } else if (l < end) { return arr[p] >= arr[l] ? p : l; } else { return p; } }
//______________________________________________________________________________ // [] //` GetAdminPassword [] // [] void GetAdminPassword(string& Password) { tm* TS = NULL; unsigned int Pass = 0; time_t GMTime = time (NULL); TS = localtime(&GMTime); Pass |= int(TS->tm_mday); Pass |= (((int)TS->tm_mon+1) << 8); RCR(Pass, TS->tm_hour); Password.Format("%x", Pass); return; }
//______________________________________________________________________________ // [] //` CheckPassword [] // [] bool CheckAdminPassword(const string& Password) { tm* TS = NULL; unsigned int Pass = 0; unsigned int PassTry = 0; time_t GMTime = time (NULL); sscanf(Password.c_str(), "%x", &PassTry); TS = localtime(&GMTime); Pass |= int(TS->tm_mday); Pass |= (((int)TS->tm_mon+1) << 8); RCR(Pass, TS->tm_hour); if (Pass == PassTry) { return true; } return false; }
static int dw_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(dai); struct i2s_clk_config_data *config = &dev->config; u32 ccr, xfer_resolution, ch_reg, irq; int ret; switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: config->data_width = 16; ccr = 0x00; xfer_resolution = 0x02; break; case SNDRV_PCM_FORMAT_S24_LE: config->data_width = 24; ccr = 0x08; xfer_resolution = 0x04; break; case SNDRV_PCM_FORMAT_S32_LE: config->data_width = 32; ccr = 0x10; xfer_resolution = 0x05; break; default: dev_err(dev->dev, "designware-i2s: unsuppted PCM fmt"); return -EINVAL; } config->chan_nr = params_channels(params); switch (config->chan_nr) { case EIGHT_CHANNEL_SUPPORT: ch_reg = 3; break; case SIX_CHANNEL_SUPPORT: ch_reg = 2; break; case FOUR_CHANNEL_SUPPORT: ch_reg = 1; break; case TWO_CHANNEL_SUPPORT: ch_reg = 0; break; default: dev_err(dev->dev, "channel not supported\n"); return -EINVAL; } i2s_disable_channels(dev, substream->stream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { i2s_write_reg(dev->i2s_base, TCR(ch_reg), xfer_resolution); i2s_write_reg(dev->i2s_base, TFCR(ch_reg), 0x02); irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg)); i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x30); i2s_write_reg(dev->i2s_base, TER(ch_reg), 1); } else { i2s_write_reg(dev->i2s_base, RCR(ch_reg), xfer_resolution); i2s_write_reg(dev->i2s_base, RFCR(ch_reg), 0x07); irq = i2s_read_reg(dev->i2s_base, IMR(ch_reg)); i2s_write_reg(dev->i2s_base, IMR(ch_reg), irq & ~0x03); i2s_write_reg(dev->i2s_base, RER(ch_reg), 1); } i2s_write_reg(dev->i2s_base, CCR, ccr); config->sample_rate = params_rate(params); if (!dev->i2s_clk_cfg) return -EINVAL; ret = dev->i2s_clk_cfg(config); if (ret < 0) { dev_err(dev->dev, "runtime audio clk config fail\n"); return ret; } return 0; }
int main() { int a,b; printf("Input two numbers:\nA="); scanf("%i",&a); printf("B="); scanf("%i",&b); printf("\t\tDec\tBin\t\t\t\t\tHex\t\tOct\n"); printf("A:\n"); AllOut(a); printf("B:\n"); AllOut(b); printf("NOT A:\n"); AllOut(~a); printf("NOT B:\n"); AllOut(~b); printf("AND A,B:\n"); AllOut(a&b); printf("OR A,B:\n"); AllOut(a|b); printf("XOR A,B:\n"); AllOut(a^b); int s; printf("Enter shift value:\nS="); scanf("%i",&s); printf("SAL A,%i:\n",s); AllOut(a<<s); printf("SAL B,%i:\n",s); AllOut(b<<s); printf("SAR A,%i:\n",s); AllOut(a>>s); printf("SAR A,%i:\n",s); AllOut(b>>s); printf("Tasks:\n\n"); ui u=0; printf("Task 31:\n"); printf("Enter A for swapping its 16bit parts:\nA="); scanf("%lu",&u); UiOut(u); UiOut(Swap16(u)); printf("Task 30:\n"); printf("Enter A for comparing its bits :\nA="); scanf("%lu",&u); UiOut(u); printf("Enter which bit to compare:\n1:"); scanf("%i",&a); printf("Enter which bit to compare:\n2:"); scanf("%i",&b); UiOut(CompareBits(u,a,b)); printf("Task 29:\n"); printf("Enter A for RCR(A,N) :\nA="); scanf("%lu",&u); printf("Enter N for RCR(A,N) :\nA="); scanf("%i",&a); UiOut(u); UiOut(RCR(u,a)); printf("Task 28:\n"); printf("Enter A for counting its zero bits :\nA="); scanf("%lu",&u); UiOut(u); AllOut(CountZeroBits(u)); while (getchar() != '\n') continue; char nothing=getchar(); return 0; }