qcacmn: Read only the useful 2 bytes of an FFT bin in pack-mode 0
FFT bin is 10-bit wide in Spectral pack-modes 0 and 1. However, HW packs just one FFT bin in a 32-bit DWORD by adding extra padding bits in pack-mode 0. Currently, the Host reads the entire 32-bit DWORD to figure out the FFT bin value. Instead, read the only useful bytes i.e., least significant 2 bytes of a DWORD. This approach is efficient, especially on a Host that implements a byte-swap mechanism on FFT bins on a big-endian Host. Also, while dumping FFT bins for debug purpose, print the first 2 bytes of an FFT bin in pack-modes 0 and 1. Change-Id: I20ca8c4905671e80251dca07f80ce17801b98f5c CRs-Fixed: 2831530
This commit is contained in:
parent
69c17ec173
commit
53b3234b8f
@ -44,7 +44,6 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
|
||||
struct target_if_spectral_ops *p_sops = NULL;
|
||||
uint32_t *binptr_32 = NULL;
|
||||
uint16_t *binptr_16 = NULL;
|
||||
uint32_t pwr_32;
|
||||
uint16_t pwr_16;
|
||||
int idx = 0;
|
||||
struct spectral_samp_data *samp_data;
|
||||
@ -167,10 +166,11 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
|
||||
SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) {
|
||||
binptr_32 = (uint32_t *)bin_pwr_data;
|
||||
for (idx = 0; idx < pwr_count; idx++) {
|
||||
pwr_32 = *(binptr_32++);
|
||||
if (qdf_unlikely(pwr_32 > MAX_FFTBIN_VALUE))
|
||||
pwr_32 = MAX_FFTBIN_VALUE;
|
||||
samp_data->bin_pwr[idx] = pwr_32;
|
||||
/* Read only the first 2 bytes of the DWORD */
|
||||
pwr_16 = *((uint16_t *)binptr_32++);
|
||||
if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE))
|
||||
pwr_16 = MAX_FFTBIN_VALUE;
|
||||
samp_data->bin_pwr[idx] = pwr_16;
|
||||
}
|
||||
} else if (swar->fftbin_size_war ==
|
||||
SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) {
|
||||
@ -257,10 +257,11 @@ target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
|
||||
SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) {
|
||||
binptr_32 = (uint32_t *)bin_pwr_data;
|
||||
for (idx = 0; idx < pwr_count_sec80; idx++) {
|
||||
pwr_32 = *(binptr_32++);
|
||||
if (qdf_unlikely(pwr_32 > MAX_FFTBIN_VALUE))
|
||||
pwr_32 = MAX_FFTBIN_VALUE;
|
||||
samp_data->bin_pwr_sec80[idx] = pwr_32;
|
||||
/* Read only the first 2 bytes of the DWORD */
|
||||
pwr_16 = *((uint16_t *)binptr_32++);
|
||||
if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE))
|
||||
pwr_16 = MAX_FFTBIN_VALUE;
|
||||
samp_data->bin_pwr_sec80[idx] = pwr_16;
|
||||
}
|
||||
} else if (swar->fftbin_size_war ==
|
||||
SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) {
|
||||
|
@ -1394,6 +1394,7 @@ target_if_dump_fft_report_gen3(struct target_if_spectral *spectral,
|
||||
size_t fft_bin_size;
|
||||
size_t fft_bin_len_inband_tfer = 0;
|
||||
uint8_t *fft_bin_buf = NULL;
|
||||
size_t fft_bin_buf_size;
|
||||
|
||||
fft_bin_len = fft_hdr_length - spectral->rparams.fft_report_hdr_len;
|
||||
fft_bin_count = target_if_spectral_get_bin_count_after_len_adj(
|
||||
@ -1444,6 +1445,8 @@ target_if_dump_fft_report_gen3(struct target_if_spectral *spectral,
|
||||
spectral_debug("fft_avgpwr_db = %u", p_sfft->fft_avgpwr_db);
|
||||
spectral_debug("fft_relpwr_db = %u", p_sfft->fft_relpwr_db);
|
||||
|
||||
fft_bin_buf_size = fft_bin_count;
|
||||
|
||||
if (fft_bin_count > 0) {
|
||||
int idx;
|
||||
|
||||
@ -1451,29 +1454,56 @@ target_if_dump_fft_report_gen3(struct target_if_spectral *spectral,
|
||||
if (spectral->len_adj_swar.fftbin_size_war ==
|
||||
SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) {
|
||||
uint32_t *binptr_32 = (uint32_t *)&p_fft_report->buf;
|
||||
uint16_t *fft_bin_buf_16 = NULL;
|
||||
|
||||
fft_bin_buf = (uint8_t *)qdf_mem_malloc(MAX_NUM_BINS);
|
||||
if (!fft_bin_buf) {
|
||||
/* Useful width of FFT bin is 10 bits, increasing it to
|
||||
* byte boundary makes it 2 bytes. Hence, buffer to be
|
||||
* allocated should be of size fft_bin_count
|
||||
* multiplied by 2.
|
||||
*/
|
||||
fft_bin_buf_size <<= 1;
|
||||
|
||||
fft_bin_buf_16 = (uint16_t *)qdf_mem_malloc(
|
||||
fft_bin_buf_size);
|
||||
if (!fft_bin_buf_16) {
|
||||
spectral_err("Failed to allocate memory");
|
||||
return;
|
||||
}
|
||||
|
||||
for (idx = 0; idx < fft_bin_count; idx++)
|
||||
fft_bin_buf[idx] = *(binptr_32++);
|
||||
fft_bin_buf_16[idx] =
|
||||
*((uint16_t *)binptr_32++);
|
||||
|
||||
fft_bin_buf = (uint8_t *)fft_bin_buf_16;
|
||||
} else if (spectral->len_adj_swar.fftbin_size_war ==
|
||||
SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) {
|
||||
uint16_t *binptr_16 = (uint16_t *)&p_fft_report->buf;
|
||||
uint16_t *fft_bin_buf_16 = NULL;
|
||||
|
||||
fft_bin_buf = (uint8_t *)qdf_mem_malloc(MAX_NUM_BINS);
|
||||
if (!fft_bin_buf) {
|
||||
/* Useful width of FFT bin is 10 bits, increasing it to
|
||||
* byte boundary makes it 2 bytes. Hence, buffer to be
|
||||
* allocated should be of size fft_bin_count
|
||||
* multiplied by 2.
|
||||
*/
|
||||
fft_bin_buf_size <<= 1;
|
||||
|
||||
fft_bin_buf_16 = (uint16_t *)qdf_mem_malloc(
|
||||
fft_bin_buf_size);
|
||||
if (!fft_bin_buf_16) {
|
||||
spectral_err("Failed to allocate memory");
|
||||
return;
|
||||
}
|
||||
|
||||
for (idx = 0; idx < fft_bin_count; idx++)
|
||||
fft_bin_buf[idx] = *(binptr_16++);
|
||||
fft_bin_buf_16[idx] = *(binptr_16++);
|
||||
|
||||
fft_bin_buf = (uint8_t *)fft_bin_buf_16;
|
||||
} else {
|
||||
fft_bin_buf = (uint8_t *)&p_fft_report->buf;
|
||||
}
|
||||
target_if_spectral_hexdump(fft_bin_buf, fft_bin_count);
|
||||
|
||||
spectral_debug("FFT bin buffer size = %zu", fft_bin_buf_size);
|
||||
target_if_spectral_hexdump(fft_bin_buf, fft_bin_buf_size);
|
||||
if ((spectral->len_adj_swar.fftbin_size_war !=
|
||||
SPECTRAL_FFTBIN_SIZE_NO_WAR) && fft_bin_buf)
|
||||
qdf_mem_free(fft_bin_buf);
|
||||
|
Loading…
Reference in New Issue
Block a user