summaryrefslogtreecommitdiffstats
path: root/firmware/export/power.h
blob: 4937705910e0d996900233e4482e894a9e02149f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2002 by Linus Nielsen Feltzing
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/
#ifndef _POWER_H_
#define _POWER_H_

#include "config.h"

#if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SAMSUNG_YPR0)
#if CONFIG_CHARGING
enum power_input_flags {
    /* No external power source? Default. */
    POWER_INPUT_NONE = 0x00,
 
    /* Main power source is available (AC?), the default other than
     * battery if for instance USB and others cannot be distinguished or
     * USB is the only possibility. */
    POWER_INPUT_MAIN = 0x01,

    /* USB power source is available (and is discernable from MAIN). */
    POWER_INPUT_USB  = 0x02,

    /* Something is plugged. */
    POWER_INPUT = 0x0f,

    /* POWER_INPUT_*_CHARGER of course implies presence of the respective
     * power source. */

    /* Battery not included in CHARGER (it can't charge itself) */

    /* Charging is possible on main. */
    POWER_INPUT_MAIN_CHARGER = 0x10 | POWER_INPUT_MAIN,

    /* Charging is possible on USB. */
    POWER_INPUT_USB_CHARGER = 0x20 | POWER_INPUT_USB,

    /* Charging is possible from something. */
    POWER_INPUT_CHARGER = 0xf0,

#ifdef HAVE_BATTERY_SWITCH
    /* Battery is powering device or is available to power device. It
     * could also be used if the battery is hot-swappable to indicate if
     * it is present ("switch" as verb vs. noun). */
    POWER_INPUT_BATTERY = 0x100,
#endif
};

/* Returns detailed power input status information from device. */
unsigned int power_input_status(void);

/* Shortcuts */
/* Returns true if any power source that is connected is capable of
 * charging the batteries.
 * > (power_input_status() & POWER_INPUT_CHARGER) != 0 */
bool charger_inserted(void);

/* Returns true if any power input is connected - charging-capable
 * or not.
 * > (power_input_status() & POWER_INPUT) != 0 */
bool power_input_present(void);
#endif /* CONFIG_CHARGING */

void power_off(void);
void ide_power_enable(bool on);

#if CONFIG_CHARGING >= CHARGING_MONITOR
bool charging_state(void);
#endif

#if (CONFIG_PLATFORM & PLATFORM_NATIVE)

void power_init(void) INIT_ATTR;

bool ide_powered(void);
#endif

#ifdef HAVE_SPDIF_POWER
void spdif_power_enable(bool on);
bool spdif_powered(void);
#endif

#if CONFIG_TUNER
bool tuner_power(bool status);
bool tuner_powered(void);
#endif

#endif

#endif /* _POWER_H_ */