summaryrefslogtreecommitdiff
path: root/drivers/media/dvb-frontends/drx39xyj/drx39xxj_dummy.c
blob: 61e04c68db41bd77da3dd3a5cf884671f1cc3794 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
#include <linux/types.h>

#include "drx_driver.h"
#include "drx39xxj.h"

/* Dummy function to satisfy drxj.c */
int drxbsp_tuner_open(struct tuner_instance *tuner)
{
	return DRX_STS_OK;
}

int drxbsp_tuner_close(struct tuner_instance *tuner)
{
	return DRX_STS_OK;
}

int drxbsp_tuner_set_frequency(struct tuner_instance *tuner,
				      u32 mode,
				      s32 center_frequency)
{
	return DRX_STS_OK;
}

int
drxbsp_tuner_get_frequency(struct tuner_instance *tuner,
			  u32 mode,
			  s32 *r_ffrequency,
			  s32 *i_ffrequency)
{
	return DRX_STS_OK;
}

int drxbsp_hst_sleep(u32 n)
{
	msleep(n);
	return DRX_STS_OK;
}

u32 drxbsp_hst_clock(void)
{
	return jiffies_to_msecs(jiffies);
}

int drxbsp_hst_memcmp(void *s1, void *s2, u32 n)
{
	return (memcmp(s1, s2, (size_t) n));
}

void *drxbsp_hst_memcpy(void *to, void *from, u32 n)
{
	return (memcpy(to, from, (size_t) n));
}

int drxbsp_i2c_write_read(struct i2c_device_addr *w_dev_addr,
				 u16 w_count,
				 u8 *wData,
				 struct i2c_device_addr *r_dev_addr,
				 u16 r_count, u8 *r_data)
{
	struct drx39xxj_state *state;
	struct i2c_msg msg[2];
	unsigned int num_msgs;

	if (w_dev_addr == NULL) {
		/* Read only */
		state = r_dev_addr->user_data;
		msg[0].addr = r_dev_addr->i2c_addr >> 1;
		msg[0].flags = I2C_M_RD;
		msg[0].buf = r_data;
		msg[0].len = r_count;
		num_msgs = 1;
	} else if (r_dev_addr == NULL) {
		/* Write only */
		state = w_dev_addr->user_data;
		msg[0].addr = w_dev_addr->i2c_addr >> 1;
		msg[0].flags = 0;
		msg[0].buf = wData;
		msg[0].len = w_count;
		num_msgs = 1;
	} else {
		/* Both write and read */
		state = w_dev_addr->user_data;
		msg[0].addr = w_dev_addr->i2c_addr >> 1;
		msg[0].flags = 0;
		msg[0].buf = wData;
		msg[0].len = w_count;
		msg[1].addr = r_dev_addr->i2c_addr >> 1;
		msg[1].flags = I2C_M_RD;
		msg[1].buf = r_data;
		msg[1].len = r_count;
		num_msgs = 2;
	}

	if (state->i2c == NULL) {
		printk("i2c was zero, aborting\n");
		return 0;
	}
	if (i2c_transfer(state->i2c, msg, num_msgs) != num_msgs) {
		printk(KERN_WARNING "drx3933: I2C write/read failed\n");
		return -EREMOTEIO;
	}

	return DRX_STS_OK;

#ifdef DJH_DEBUG
	struct drx39xxj_state *state = w_dev_addr->user_data;

	struct i2c_msg msg[2] = {
		{.addr = w_dev_addr->i2c_addr,
		 .flags = 0, .buf = wData, .len = w_count},
		{.addr = r_dev_addr->i2c_addr,
		 .flags = I2C_M_RD, .buf = r_data, .len = r_count},
	};

	printk("drx3933 i2c operation addr=%x i2c=%p, wc=%x rc=%x\n",
	       w_dev_addr->i2c_addr, state->i2c, w_count, r_count);

	if (i2c_transfer(state->i2c, msg, 2) != 2) {
		printk(KERN_WARNING "drx3933: I2C write/read failed\n");
		return -EREMOTEIO;
	}
#endif
	return 0;
}