mirror of
https://github.com/openharmony/device_board_osware.git
synced 2026-07-20 01:33:32 -04:00
modify beta2 format
Signed-off-by: zhaoxc0502 <zhaoxc0502@thundersoft.com>
This commit is contained in:
@@ -722,33 +722,8 @@ struct AudioPcmHwParams g_PcmParams = {0};
|
||||
#define FORMAT_HW (16385)
|
||||
#define RATE_MULTIPLE (10)
|
||||
#define LOW_SAMPLE_RATES (24000)
|
||||
int Wm8904DaiHwParamsSet(const struct AudioCard *card, const struct AudioPcmHwParams *param)
|
||||
int WM8904GetAif1(int width, unsigned int *aif1)
|
||||
{
|
||||
int fs = 0, width = 0, channel = 0, slots = 0, dir = 0;
|
||||
int ret = 0, i = 0, best = 0, best_val = 0, cur_val = 0, errno = 0;
|
||||
unsigned int aif1 = 0, aif2 = 0, aif3 = 0, clock1 = 0, dac_digital1 = 0;
|
||||
|
||||
errno = memcpy_s(&g_PcmParams, sizeof(struct AudioPcmHwParams), param, sizeof(struct AudioPcmHwParams));
|
||||
if (errno != 0) {
|
||||
WM8904_CODEC_LOG_ERR("Memcpy pcm parameters failed!");
|
||||
}
|
||||
|
||||
fs = param->rate;
|
||||
Frame_To_Bit_Width(param->format, &width);
|
||||
channel = param->channels;
|
||||
slots = 1;
|
||||
|
||||
dir = param->streamType == AUDIO_RENDER_STREAM ? 1 : 0;
|
||||
|
||||
WM8904_Set_Fmt(FORMAT_HW);
|
||||
msleep(SLEEP_TIME_10);
|
||||
WM8904_Set_Sysclk(1, 0);
|
||||
msleep(SLEEP_TIME_10);
|
||||
|
||||
/* What BCLK do we need? */
|
||||
gpwm8904->fs = fs;
|
||||
gpwm8904->bclk = fs * width * channel * slots;
|
||||
|
||||
switch (width) {
|
||||
case BIT_WIDTH_16:
|
||||
break;
|
||||
@@ -764,14 +739,13 @@ int Wm8904DaiHwParamsSet(const struct AudioCard *card, const struct AudioPcmHwPa
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
ret = WM8904_Configure_Clocking();
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WM8904HwParamsGetClkRate(unsigned int *dac_digital1, unsigned int *aif2, unsigned int *aif3, unsigned int *clock1)
|
||||
{
|
||||
int ret = 0, i = 0, best = 0, best_val = 0, cur_val = 0;
|
||||
/* Select nearest CLK_SYS_RATE */
|
||||
best = 0;
|
||||
best_val = abs((gpwm8904->sysclk_rate / clk_sys_rates[0].ratio) - gpwm8904->fs);
|
||||
for (i = 1; i < ARRAY_SIZE(clk_sys_rates); i++) {
|
||||
cur_val = abs((gpwm8904->sysclk_rate / clk_sys_rates[i].ratio) - gpwm8904->fs);
|
||||
@@ -780,7 +754,7 @@ int Wm8904DaiHwParamsSet(const struct AudioCard *card, const struct AudioPcmHwPa
|
||||
best_val = cur_val;
|
||||
}
|
||||
}
|
||||
clock1 |= (clk_sys_rates[best].clk_sys_rate << WM8904_CLK_SYS_RATE_SHIFT);
|
||||
*clock1 |= (clk_sys_rates[best].clk_sys_rate << WM8904_CLK_SYS_RATE_SHIFT);
|
||||
|
||||
/* SAMPLE_RATE */
|
||||
best = 0;
|
||||
@@ -793,12 +767,12 @@ int Wm8904DaiHwParamsSet(const struct AudioCard *card, const struct AudioPcmHwPa
|
||||
best_val = cur_val;
|
||||
}
|
||||
}
|
||||
WM8904_CODEC_LOG_DEBUG("Selected SAMPLE_RATE of %dHz", sample_rates[best].rate);
|
||||
clock1 |= (sample_rates[best].sample_rate << WM8904_SAMPLE_RATE_SHIFT);
|
||||
WM8904_CODEC_LOG_DEBUG("Selected SAMPLE_RATE of %dHz", sample_rates[best].rate);
|
||||
*clock1 |= (sample_rates[best].sample_rate << WM8904_SAMPLE_RATE_SHIFT);
|
||||
|
||||
/* Enable sloping stopband filter for low sample rates */
|
||||
if (gpwm8904->fs <= LOW_SAMPLE_RATES) {
|
||||
dac_digital1 |= WM8904_DAC_SB_FILT;
|
||||
*dac_digital1 |= WM8904_DAC_SB_FILT;
|
||||
}
|
||||
|
||||
/* BCLK_DIV */
|
||||
@@ -815,17 +789,51 @@ int Wm8904DaiHwParamsSet(const struct AudioCard *card, const struct AudioPcmHwPa
|
||||
}
|
||||
}
|
||||
gpwm8904->bclk = (gpwm8904->sysclk_rate * RATE_MULTIPLE) / bclk_divs[best].div;
|
||||
*aif2 |= bclk_divs[best].bclk_div;
|
||||
*aif3 |= gpwm8904->bclk / gpwm8904->fs;
|
||||
}
|
||||
|
||||
aif2 |= bclk_divs[best].bclk_div;
|
||||
aif3 |= gpwm8904->bclk / gpwm8904->fs;
|
||||
int Wm8904DaiHwParamsSet(const struct AudioCard *card, const struct AudioPcmHwParams *param)
|
||||
{
|
||||
int fs = 0, width = 0, channel = 0, slots = 1, dir = 0, ret = 0, errno = 0;
|
||||
unsigned int aif1 = 0, aif2 = 0, aif3 = 0, clock1 = 0, dac_digital1 = 0;
|
||||
|
||||
errno = memcpy_s(&g_PcmParams, sizeof(struct AudioPcmHwParams), param, sizeof(struct AudioPcmHwParams));
|
||||
if (errno != 0) {
|
||||
WM8904_CODEC_LOG_ERR("Memcpy pcm parameters failed!");
|
||||
}
|
||||
|
||||
fs = param->rate;
|
||||
channel = param->channels;
|
||||
dir = param->streamType == AUDIO_RENDER_STREAM ? 1 : 0;
|
||||
Frame_To_Bit_Width(param->format, &width);
|
||||
|
||||
WM8904_Set_Fmt(FORMAT_HW);
|
||||
msleep(SLEEP_TIME_10);
|
||||
WM8904_Set_Sysclk(1, 0);
|
||||
msleep(SLEEP_TIME_10);
|
||||
|
||||
/* What BCLK do we need? */
|
||||
gpwm8904->fs = fs;
|
||||
gpwm8904->bclk = fs * width * channel * slots;
|
||||
|
||||
ret = WM8904GetAif1(&aif1);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = WM8904_Configure_Clocking();
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
WM8904HwParamsGetClkRate(&dac_digital1, &aif2, &aif3, &clock1);
|
||||
|
||||
/* Apply the settings */
|
||||
WM8904RegUpdateBits(g_wm8904_i2c_handle, WM8904_DAC_DIGITAL_1, WM8904_DAC_SB_FILT, dac_digital1, BYTE_NUM);
|
||||
WM8904RegUpdateBits(g_wm8904_i2c_handle, WM8904_AUDIO_INTERFACE_1, WM8904_AIF_WL_MASK, aif1, BYTE_NUM);
|
||||
WM8904RegUpdateBits(g_wm8904_i2c_handle, WM8904_AUDIO_INTERFACE_2, WM8904_BCLK_DIV_MASK, aif2, BYTE_NUM);
|
||||
WM8904RegUpdateBits(g_wm8904_i2c_handle, WM8904_AUDIO_INTERFACE_3, WM8904_LRCLK_RATE_MASK, aif3, BYTE_NUM);
|
||||
WM8904RegUpdateBits(g_wm8904_i2c_handle, WM8904_CLOCK_RATES_1,
|
||||
WM8904_SAMPLE_RATE_MASK | WM8904_CLK_SYS_RATE_MASK, clock1, BYTE_NUM);
|
||||
WM8904RegUpdateBits(g_wm8904_i2c_handle, WM8904_CLOCK_RATES_1, WM8904_SAMPLE_RATE_MASK | WM8904_CLK_SYS_RATE_MASK, clock1, BYTE_NUM);
|
||||
|
||||
/* Update filters for the new settings */
|
||||
WM8904_Set_Retune_Mobile();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -713,27 +713,13 @@ int32_t WalDisconnect(NetDevice *netDev, uint16_t reasonCode)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
struct cfg80211_scan_request g_request;
|
||||
int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
|
||||
int32_t WalBuildChannelInfo(struct wiphy* wiphy, struct WlanScanRequest *scanParam,
|
||||
struct cfg80211_scan_request **request)
|
||||
{
|
||||
int32_t loop;
|
||||
int32_t count = 0;
|
||||
int32_t retVal = 0;
|
||||
enum Ieee80211Band band = IEEE80211_BAND_2GHZ;
|
||||
struct ieee80211_channel *chan = NULL;
|
||||
struct wiphy* wiphy = wrap_get_wiphy();
|
||||
|
||||
struct cfg80211_scan_request *request = &g_request;
|
||||
|
||||
if (request == NULL) {
|
||||
HDF_LOGE("%s: calloc request null!\n", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
// basic info
|
||||
request->wiphy = wiphy;
|
||||
request->wdev = GET_NET_DEV_CFG80211_WIRELESS(netDev);
|
||||
request->n_ssids = scanParam->ssidCount;
|
||||
enum Ieee80211Band band = IEEE80211_BAND_2GHZ;
|
||||
|
||||
// channel info
|
||||
if ((scanParam->freqs == NULL) || (scanParam->freqsCount == 0)) {
|
||||
@@ -747,17 +733,16 @@ int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
|
||||
if ((chan->flags & WIFI_CHAN_DISABLED) != 0) {
|
||||
continue;
|
||||
}
|
||||
request->channels[count++] = chan;
|
||||
(*request)->channels[count++] = chan;
|
||||
}
|
||||
} else {
|
||||
for (loop = 0; loop < scanParam->freqsCount; loop++) {
|
||||
chan = GetChannelByFreq(wiphy, (uint16_t)(scanParam->freqs[loop]));
|
||||
if (chan == NULL) {
|
||||
HDF_LOGE("%s: freq not found!freq=%d!\n", __func__, scanParam->freqs[loop]);
|
||||
continue;
|
||||
}
|
||||
|
||||
request->channels[count++] = chan;
|
||||
(*request)->channels[count++] = chan;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -765,11 +750,14 @@ int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
|
||||
HDF_LOGE("%s: invalid freq info!\n", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
request->n_channels = count;
|
||||
(*request)->n_channels = count;
|
||||
|
||||
// ssid info
|
||||
count = 0;
|
||||
loop = 0;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t WalBuildSSidInfo(struct WlanScanRequest *scanParam, struct cfg80211_scan_request **request)
|
||||
{
|
||||
int32_t loop, count = 0, retVal = 0;
|
||||
if (scanParam->ssidCount > WPAS_MAX_SCAN_SSIDS) {
|
||||
HDF_LOGE("%s:unexpected numSsids!numSsids=%u", __func__, scanParam->ssidCount);
|
||||
return HDF_FAILURE;
|
||||
@@ -780,7 +768,7 @@ int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
request->ssids = (struct cfg80211_ssid *)OsalMemCalloc(scanParam->ssidCount * sizeof(struct cfg80211_ssid));
|
||||
(*request)->ssids = (struct cfg80211_ssid *)OsalMemCalloc(scanParam->ssidCount * sizeof(struct cfg80211_ssid));
|
||||
if (request->ssids == NULL) {
|
||||
HDF_LOGE("%s: calloc request->ssids null", __func__);
|
||||
return HDF_FAILURE;
|
||||
@@ -795,25 +783,53 @@ int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
|
||||
continue;
|
||||
}
|
||||
|
||||
request->ssids[count].ssid_len = scanParam->ssids[loop].ssidLen;
|
||||
if (memcpy_s(request->ssids[count].ssid, OAL_IEEE80211_MAX_SSID_LEN, scanParam->ssids[loop].ssid,
|
||||
(*request)->ssids[count].ssid_len = scanParam->ssids[loop].ssidLen;
|
||||
if (memcpy_s((*request)->ssids[count].ssid, OAL_IEEE80211_MAX_SSID_LEN, scanParam->ssids[loop].ssid,
|
||||
scanParam->ssids[loop].ssidLen) != 0) {
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
request->n_ssids = count;
|
||||
(*request)->n_ssids = count;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
struct cfg80211_scan_request g_request;
|
||||
int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
|
||||
{
|
||||
int32_t loop, count = 0, retVal = 0;
|
||||
enum Ieee80211Band band = IEEE80211_BAND_2GHZ;
|
||||
struct ieee80211_channel *chan = NULL;
|
||||
struct wiphy* wiphy = wrap_get_wiphy();
|
||||
struct cfg80211_scan_request *request = &g_request;
|
||||
|
||||
if (request == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
// basic info
|
||||
request->wiphy = wiphy;
|
||||
request->wdev = GET_NET_DEV_CFG80211_WIRELESS(netDev);
|
||||
request->n_ssids = scanParam->ssidCount;
|
||||
|
||||
if (WalBuildChannelInfo(wiphy, scanParam, &request) == HDF_FAILURE) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
// ssid info
|
||||
if (WalBuildSSidInfo(scanParam, &request) == HDF_FAILURE) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
// User Ie Info
|
||||
if (scanParam->extraIEsLen > 512) {
|
||||
HDF_LOGE("%s:unexpected extra len!extraIesLen=%d", __func__, scanParam->extraIEsLen);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if ((scanParam->extraIEs != NULL) && (scanParam->extraIEsLen != 0)) {
|
||||
request->ie = (uint8_t *)OsalMemCalloc(scanParam->extraIEsLen);
|
||||
if (request->ie == NULL) {
|
||||
HDF_LOGE("%s: calloc request->ie null", __func__);
|
||||
if (request->ie != NULL) {
|
||||
OsalMemFree((void*)request->ie);
|
||||
request->ie = NULL;
|
||||
@@ -827,7 +843,6 @@ int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
|
||||
|
||||
retVal = (int32_t)wl_cfg80211_ops.scan(wiphy, request);
|
||||
if (retVal < 0) {
|
||||
HDF_LOGE("%s: scan Failed!", __func__);
|
||||
if (request != NULL) {
|
||||
if ((request)->ie != NULL) {
|
||||
OsalMemFree((void*)(request->ie));
|
||||
@@ -840,8 +855,6 @@ int32_t WalStartScan(NetDevice *netDev, struct WlanScanRequest *scanParam)
|
||||
OsalMemFree(request);
|
||||
request = NULL;
|
||||
}
|
||||
} else {
|
||||
HDF_LOGE("%s: scan OK!", __func__);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
Reference in New Issue
Block a user