Root/target/linux/s3c24xx/files-2.6.30/drivers/ar6000/wlan/wlan_utils.c

1/*
2 * Copyright (c) 2004-2005 Atheros Communications Inc.
3 * All rights reserved.
4 *
5 * This module implements frequently used wlan utilies
6 *
7 * $Id: //depot/sw/releases/olca2.0-GPL/host/wlan/src/wlan_utils.c#1 $
8 *
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation;
13 *
14 * Software distributed under the License is distributed on an "AS
15 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
16 * implied. See the License for the specific language governing
17 * rights and limitations under the License.
18 *
19 *
20 *
21 */
22
23#include <a_config.h>
24#include <athdefs.h>
25#include <a_types.h>
26#include <a_osapi.h>
27
28/*
29 * converts ieee channel number to frequency
30 */
31A_UINT16
32wlan_ieee2freq(int chan)
33{
34    if (chan == 14) {
35        return 2484;
36    }
37    if (chan < 14) { /* 0-13 */
38        return (2407 + (chan*5));
39    }
40    if (chan < 27) { /* 15-26 */
41        return (2512 + ((chan-15)*20));
42    }
43    return (5000 + (chan*5));
44}
45
46/*
47 * Converts MHz frequency to IEEE channel number.
48 */
49A_UINT32
50wlan_freq2ieee(A_UINT16 freq)
51{
52    if (freq == 2484)
53        return 14;
54    if (freq < 2484)
55        return (freq - 2407) / 5;
56    if (freq < 5000)
57        return 15 + ((freq - 2512) / 20);
58    return (freq - 5000) / 5;
59}
60

Archive Download this file



interactive