GNU Linux-libre 4.19.264-gnu1
[releases.git] / drivers / staging / rtl8188eu / core / rtw_rf.c
1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 #define _RTW_RF_C_
8
9 #include <osdep_service.h>
10 #include <drv_types.h>
11 #include <recv_osdep.h>
12 #include <xmit_osdep.h>
13
14 struct ch_freq {
15         u32 channel;
16         u32 frequency;
17 };
18
19 static struct ch_freq ch_freq_map[] = {
20         {1, 2412}, {2, 2417}, {3, 2422}, {4, 2427}, {5, 2432},
21         {6, 2437}, {7, 2442}, {8, 2447}, {9, 2452}, {10, 2457},
22         {11, 2462}, {12, 2467}, {13, 2472}, {14, 2484},
23         /*  UNII */
24         {36, 5180}, {40, 5200}, {44, 5220}, {48, 5240}, {52, 5260},
25         {56, 5280}, {60, 5300}, {64, 5320}, {149, 5745}, {153, 5765},
26         {157, 5785}, {161, 5805}, {165, 5825}, {167, 5835}, {169, 5845},
27         {171, 5855}, {173, 5865},
28         /* HiperLAN2 */
29         {100, 5500}, {104, 5520}, {108, 5540}, {112, 5560}, {116, 5580},
30         {120, 5600}, {124, 5620}, {128, 5640}, {132, 5660}, {136, 5680},
31         {140, 5700},
32         /* Japan MMAC */
33         {34, 5170}, {38, 5190}, {42, 5210}, {46, 5230},
34         /*  Japan */
35         {184, 4920}, {188, 4940}, {192, 4960}, {196, 4980},
36         {208, 5040},/* Japan, means J08 */
37         {212, 5060},/* Japan, means J12 */
38         {216, 5080},/* Japan, means J16 */
39 };
40
41 static int ch_freq_map_num = ARRAY_SIZE(ch_freq_map);
42
43 u32 rtw_ch2freq(u32 channel)
44 {
45         u8      i;
46         u32     freq = 0;
47
48         for (i = 0; i < ch_freq_map_num; i++) {
49                 if (channel == ch_freq_map[i].channel) {
50                         freq = ch_freq_map[i].frequency;
51                                 break;
52                 }
53         }
54         if (i == ch_freq_map_num)
55                 freq = 2412;
56
57         return freq;
58 }