OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [media/] [video/] [zr36120_i2c.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
    zr36120_i2c.c - Zoran 36120/36125 based framegrabbers
3
 
4
    Copyright (C) 1998-1999 Pauline Middelink <middelin@polyware.nl>
5
 
6
    This program is free software; you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation; either version 2 of the License, or
9
    (at your option) any later version.
10
 
11
    This program is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
15
 
16
    You should have received a copy of the GNU General Public License
17
    along with this program; if not, write to the Free Software
18
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
*/
20
 
21
#include <linux/types.h>
22
#include <linux/delay.h>
23
#include <asm/io.h>
24
 
25
#include <linux/version.h>
26
#include <linux/video_decoder.h>
27
#include <asm/uaccess.h>
28
 
29
#include "tuner.h"
30
#include "zr36120.h"
31
 
32
/* ----------------------------------------------------------------------- */
33
/* I2C functions                                                           */
34
/* ----------------------------------------------------------------------- */
35
 
36
/* software I2C functions */
37
 
38
#define I2C_DELAY   10
39
 
40
static void i2c_setlines(struct i2c_bus *bus,int ctrl,int data)
41
{
42
        struct zoran *ztv = (struct zoran*)bus->data;
43
        unsigned int b = 0;
44
        if (data) b |= ztv->card->swapi2c ? ZORAN_I2C_SCL : ZORAN_I2C_SDA;
45
        if (ctrl) b |= ztv->card->swapi2c ? ZORAN_I2C_SDA : ZORAN_I2C_SCL;
46
        zrwrite(b, ZORAN_I2C);
47
        udelay(I2C_DELAY);
48
}
49
 
50
static int i2c_getdataline(struct i2c_bus *bus)
51
{
52
        struct zoran *ztv = (struct zoran*)bus->data;
53
        if (ztv->card->swapi2c)
54
                return zrread(ZORAN_I2C) & ZORAN_I2C_SCL;
55
        return zrread(ZORAN_I2C) & ZORAN_I2C_SDA;
56
}
57
 
58
static
59
void attach_inform(struct i2c_bus *bus, int id)
60
{
61
        struct zoran *ztv = (struct zoran*)bus->data;
62
        struct video_decoder_capability dc;
63
        int rv;
64
 
65
        switch (id) {
66
         case I2C_DRIVERID_VIDEODECODER:
67
                DEBUG(printk(CARD_INFO "decoder attached\n",CARD));
68
 
69
                /* fetch the capabilites of the decoder */
70
                rv = i2c_control_device(&ztv->i2c, I2C_DRIVERID_VIDEODECODER, DECODER_GET_CAPABILITIES, &dc);
71
                if (rv) {
72
                        DEBUG(printk(CARD_DEBUG "decoder is not V4L aware!\n",CARD));
73
                        break;
74
                }
75
                DEBUG(printk(CARD_DEBUG "capabilities %d %d %d\n",CARD,dc.flags,dc.inputs,dc.outputs));
76
 
77
                /* Test if the decoder can de VBI transfers */
78
                if (dc.flags & 16 /*VIDEO_DECODER_VBI*/)
79
                        ztv->have_decoder = 2;
80
                else
81
                        ztv->have_decoder = 1;
82
                break;
83
         case I2C_DRIVERID_TUNER:
84
                ztv->have_tuner = 1;
85
                DEBUG(printk(CARD_INFO "tuner attached\n",CARD));
86
                if (ztv->tuner_type >= 0)
87
                {
88
                        if (i2c_control_device(&ztv->i2c,I2C_DRIVERID_TUNER,TUNER_SET_TYPE,&ztv->tuner_type)<0)
89
                        DEBUG(printk(CARD_INFO "attach_inform; tuner wont be set to type %d\n",CARD,ztv->tuner_type));
90
                }
91
                break;
92
         default:
93
                DEBUG(printk(CARD_INFO "attach_inform; unknown device id=%d\n",CARD,id));
94
                break;
95
        }
96
}
97
 
98
static
99
void detach_inform(struct i2c_bus *bus, int id)
100
{
101
        struct zoran *ztv = (struct zoran*)bus->data;
102
 
103
        switch (id) {
104
         case I2C_DRIVERID_VIDEODECODER:
105
                ztv->have_decoder = 0;
106
                DEBUG(printk(CARD_INFO "decoder detached\n",CARD));
107
                break;
108
         case I2C_DRIVERID_TUNER:
109
                ztv->have_tuner = 0;
110
                DEBUG(printk(CARD_INFO "tuner detached\n",CARD));
111
                break;
112
         default:
113
                DEBUG(printk(CARD_INFO "detach_inform; unknown device id=%d\n",CARD,id));
114
                break;
115
        }
116
}
117
 
118
struct i2c_bus zoran_i2c_bus_template =
119
{
120
        "ZR36120",
121
        I2C_BUSID_ZORAN,
122
        NULL,
123
 
124
        SPIN_LOCK_UNLOCKED,
125
 
126
        attach_inform,
127
        detach_inform,
128
 
129
        i2c_setlines,
130
        i2c_getdataline,
131
        NULL,
132
        NULL
133
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.