summaryrefslogtreecommitdiffstats
path: root/src/cpufreqd/cpufreqdconnection.h
blob: 4f15ad86dc5fe4090fbcf3a2ed251f6a838a2b10 (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
/***************************************************************************
 *   Copyright (C) 2006 by Valentine Sinitsyn                              *
 *   [email protected]                                                        *
 *                                                                         *
 *   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 program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/
#ifndef CPUFREQDCONNECTION_H
#define CPUFREQDCONNECTION_H

#include <qstring.h>
#include <stdint.h>

/* Excerpt from cpufreqd_remote.h (cpufreqd-2.0.0)
 *
 * Copyright (C) 2005  Mattia Dongili <[email protected]>
 *                     Hrvoje Zeba <[email protected]>
 *
 * Format:
 *	it is an uint32_t used as bitmask
 *	
 *	31-16     15-0 
 *	<command> <arguments>
 * 
 * The response may be longer than a single line and is 
 * terminated by the RESPONSE_END (see defines).
 */

#define CMD_UPDATE_STATE	1 /* no arguments */
#define CMD_SET_PROFILE		2 /* <profile index> */
#define CMD_LIST_PROFILES	3 /* no arguments */
#define CMD_SET_RULE		4 /* <rule index> */
#define CMD_LIST_RULES		5 /* no arguments */
#define CMD_SET_MODE		6 /* <mode> */

#define ARG_DYNAMIC		(1)
#define ARG_MANUAL		(2)

class CPUFreqdConnection{
	public:
		CPUFreqdConnection();
		~CPUFreqdConnection();

		bool open();
		ssize_t read(void *buf, size_t size);
		bool write(uint32_t cmd, uint32_t arg);
		void close();

		bool available() const;
		bool lookup();

	private:
		QString m_socket;
		int m_fd;
};

#endif