qcacld-3.0: Avoid selection of irrelevant channel in 80/160MHz config

When channel list contains all channels from channel 1 to channel
165 and ch width is 80MHz, the channel to be selected as part of
ACS algorithm should be a 5GHz channel as 2.4GHz channels does not
support 80MHz but 2.4GHz channel gets selected with channel
width as 40MHz. Similarly when ch width is 160Mhz, the 160Mhz bonding
can be made only by 36-64 and 100-128 channels but 2.4Ghz channel or
some other 5Ghz channel gets selected as a result of ACS algorithm.

Assign max weight to all the 2.4GHz channels in 80Mhz and to all 2.4 Ghz
channels and 5Ghz channels not in the range 36-64 and 100-128 in 160 Mhz
so that only a valid channel is selected after the ACS algorithm is
completed.

Change-Id: I00c40e5d000a1cf8b79397fd4e361838a60b363d
CRs-Fixed: 2182011
diff --git a/core/sap/src/sap_ch_select.c b/core/sap/src/sap_ch_select.c
index 2046cd8..058a6fd 100644
--- a/core/sap/src/sap_ch_select.c
+++ b/core/sap/src/sap_ch_select.c
@@ -1911,12 +1911,16 @@
 		}
 	}
 
+	/*
+	 * Assign max weight(SAP_ACS_WEIGHT_MAX * 4) to 2.4 Ghz channels
+	 * and channel 165 as they cannot be part of a 80Mhz channel bonding.
+	 */
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
-		if (CHANNEL_165 == pSpectInfo[j].chNum) {
+		if ((pSpectInfo[j].chNum >= WLAN_REG_CH_NUM(CHAN_ENUM_1) &&
+		     pSpectInfo[j].chNum <= WLAN_REG_CH_NUM(CHAN_ENUM_14)) ||
+		    (CHANNEL_165 == pSpectInfo[j].chNum))
 			pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 4;
-			break;
-		}
 	}
 
 	sap_sort_chl_weight(pSpectInfoParams);
@@ -2051,12 +2055,18 @@
 		pSpectInfo[j + minIdx].weight = acs_vht160_channels[i].weight;
 	}
 
+	/*
+	 * Assign max weight(SAP_ACS_WEIGHT_MAX * 8) to 2.4 Ghz channels
+	 * and channel 132-165 as they cannot be part of a 160Mhz channel
+	 * bonding.
+	 */
 	pSpectInfo = pSpectInfoParams->pSpectCh;
 	for (j = 0; j < pSpectInfoParams->numSpectChans; j++) {
-		if (CHANNEL_165 == pSpectInfo[j].chNum) {
+		if ((pSpectInfo[j].chNum >= WLAN_REG_CH_NUM(CHAN_ENUM_1) &&
+		     pSpectInfo[j].chNum <= WLAN_REG_CH_NUM(CHAN_ENUM_14)) ||
+		    (pSpectInfo[j].chNum >= WLAN_REG_CH_NUM(CHAN_ENUM_132) &&
+		     pSpectInfo[j].chNum <= WLAN_REG_CH_NUM(CHAN_ENUM_165)))
 			pSpectInfo[j].weight = SAP_ACS_WEIGHT_MAX * 8;
-			break;
-		}
 	}
 
 	sap_sort_chl_weight(pSpectInfoParams);