2 * lnbp22.h - driver for lnb supply and control ic lnbp22
4 * Copyright (C) 2006 Dominik Kuhlen
5 * Based on lnbp21 driver
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
25 * the project's page is at http://www.linuxtv.org
27 #include <linux/delay.h>
28 #include <linux/errno.h>
29 #include <linux/init.h>
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/moduleparam.h>
33 #include <linux/string.h>
34 #include <linux/slab.h>
36 #include "dvb_frontend.h"
40 module_param(debug
, int, 0644);
41 MODULE_PARM_DESC(debug
, "Turn on/off debugging (default:off).");
44 #define dprintk(lvl, arg...) if (debug >= (lvl)) printk(arg)
48 struct i2c_adapter
*i2c
;
51 static int lnbp22_set_voltage(struct dvb_frontend
*fe
, fe_sec_voltage_t voltage
)
53 struct lnbp22
*lnbp22
= (struct lnbp22
*)fe
->sec_priv
;
54 struct i2c_msg msg
= {
57 .buf
= (char *)&lnbp22
->config
,
58 .len
= sizeof(lnbp22
->config
),
61 dprintk(1, "%s: %d (18V=%d 13V=%d)\n", __func__
, voltage
,
62 SEC_VOLTAGE_18
, SEC_VOLTAGE_13
);
64 lnbp22
->config
[3] = 0x60; /* Power down */
69 lnbp22
->config
[3] |= LNBP22_EN
;
72 lnbp22
->config
[3] |= (LNBP22_EN
| LNBP22_VSEL
);
78 dprintk(1, "%s: 0x%02x)\n", __func__
, lnbp22
->config
[3]);
79 return (i2c_transfer(lnbp22
->i2c
, &msg
, 1) == 1) ? 0 : -EIO
;
82 static int lnbp22_enable_high_lnb_voltage(struct dvb_frontend
*fe
, long arg
)
84 struct lnbp22
*lnbp22
= (struct lnbp22
*) fe
->sec_priv
;
85 struct i2c_msg msg
= {
88 .buf
= (char *)&lnbp22
->config
,
89 .len
= sizeof(lnbp22
->config
),
92 dprintk(1, "%s: %d\n", __func__
, (int)arg
);
94 lnbp22
->config
[3] |= LNBP22_LLC
;
96 lnbp22
->config
[3] &= ~LNBP22_LLC
;
98 return (i2c_transfer(lnbp22
->i2c
, &msg
, 1) == 1) ? 0 : -EIO
;
101 static void lnbp22_release(struct dvb_frontend
*fe
)
103 dprintk(1, "%s\n", __func__
);
105 lnbp22_set_voltage(fe
, SEC_VOLTAGE_OFF
);
112 struct dvb_frontend
*lnbp22_attach(struct dvb_frontend
*fe
,
113 struct i2c_adapter
*i2c
)
115 struct lnbp22
*lnbp22
= kmalloc(sizeof(struct lnbp22
), GFP_KERNEL
);
119 /* default configuration */
120 lnbp22
->config
[0] = 0x00; /* ? */
121 lnbp22
->config
[1] = 0x28; /* ? */
122 lnbp22
->config
[2] = 0x48; /* ? */
123 lnbp22
->config
[3] = 0x60; /* Power down */
125 fe
->sec_priv
= lnbp22
;
127 /* detect if it is present or not */
128 if (lnbp22_set_voltage(fe
, SEC_VOLTAGE_OFF
)) {
129 dprintk(0, "%s LNBP22 not found\n", __func__
);
135 /* install release callback */
136 fe
->ops
.release_sec
= lnbp22_release
;
138 /* override frontend ops */
139 fe
->ops
.set_voltage
= lnbp22_set_voltage
;
140 fe
->ops
.enable_high_lnb_voltage
= lnbp22_enable_high_lnb_voltage
;
144 EXPORT_SYMBOL(lnbp22_attach
);
146 MODULE_DESCRIPTION("Driver for lnb supply and control ic lnbp22");
147 MODULE_AUTHOR("Dominik Kuhlen");
148 MODULE_LICENSE("GPL");