Porting Kernel Module: 2.0.x -> 2.2.x

Porting Kernel Module: 2.0.x -> 2.2.x

Post by Oliver Wahle » Mon, 17 May 1999 04:00:00



Hi there,
I would like to use the videoteXt program that is e.g. shipped with SUSE
6.1, Kernel 2.2.5.
I had the whole software-/hardware-system working under kernel 2.0.xx.
But now I upgraded my system and the kernel-module does not compiled
under kernel 2.2.5.
The module is pretty short: just one file with about 1000 lines of code.
I would be glad, if someone having kernelexperience could take a look at
the code and help me fix it.

--
Oliver Wahlen

 
 
 

Porting Kernel Module: 2.0.x -> 2.2.x

Post by Jan Willamowi » Tue, 18 May 1999 04:00:00



>I would like to use the videoteXt program that is e.g. shipped with SUSE
>6.1, Kernel 2.2.5.
>I had the whole software-/hardware-system working under kernel 2.0.xx.
>But now I upgraded my system and the kernel-module does not compiled
>under kernel 2.2.5.

Richard Gooch has put together a list of things that changed in the kernel
API from 2.0x -> 2.2x. It can be found at

http://www.atnf.csiro.au/~rgooch/linux

--
Jan Willamowius, http://www.willamowius.de/
Microsoft has a year 2000 problem. I'm part of it. I'm running Linux.

 
 
 

Porting Kernel Module: 2.0.x -> 2.2.x

Post by Thomas Radk » Thu, 20 May 1999 04:00:00


Oliver Wahlen wrote:

> Hi there,
> I would like to use the videoteXt program that is e.g. shipped with SUSE
> 6.1, Kernel 2.2.5.
> I had the whole software-/hardware-system working under kernel 2.0.xx.
> But now I upgraded my system and the kernel-module does not compiled
> under kernel 2.2.5.
> The module is pretty short: just one file with about 1000 lines of code.
> I would be glad, if someone having kernelexperience could take a look at
> the code and help me fix it.

> --
> Oliver Wahlen

Hi,
I just spend several days proting vtx.o from 2.0.x to 2.2.5. Now it
seems to work. If you know where to put it for other users please feel
free to do it.

Thomas Radke

[ vtx.c 47K ]
/*
 * vtx.c
 *
 * Copyright (c) 1994-96 Martin Buck  <martin-2.b...@student.uni-ulm.de>
 *
 * This is a loadable character-device-driver for videotext-interfaces
 * (aka teletext). Please check the Makefile for a list of supported
 * interfaces.
 */

/*
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 * USA.
 */

#define __KERNEL__
#define MODULE
#define __NO_VERSION__
#include <linux/version.h>
#include <linux/autoconf.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <asm/io.h>
/*#include <asm/segment.h>*/
#include <asm/uaccess.h>
#include <stdarg.h>
#include "vtx.h"

#define VTX_VER_MAJ 1
#define VTX_VER_MIN 6
#define VTX_NAME "videotext"

#if (defined IF_HOMEBREW + defined IF_CT + defined IF_CTSERIAL + defined IF_VTX2000 \
    + defined IF_VTX2000EXT + defined IF_PCVT7000 + defined IF_SATCOM + defined IF_MICROTEXT \
    + defined IF_PCVTX_STD + defined IF_PCVTX_CIRC + defined IF_MBLASTER \
    + defined IF_PRIMETIME + defined IF_LPT) != 1
#error You must choose exactly one interface in the Makefile
#endif

#define BITSHIFT 1              /* Values for I2C_TYPE */
#define PCF8584 2

/* Defines for different interfaces and macros for setting/checking SDA/SCL lines:
 * set_sda(val): Set SDA-line to val (0/1)
 * set_scl(val): Set SCL-line to val (0/1)
 * get_sda(): Read state of SDA-line (0/1)
 * is_busy(), i2c_ctrl(val): Required only for i2c_reserve/release() (IF_HOMEBREW)
 */

#ifdef IF_HOMEBREW
#define set_sda(val) outb(portval = ((portval & ~1) | ((val) ? 0 : 1)), io_base)
#define set_scl(val) outb(portval = ((portval & ~2) | ((val) ? 0 : 2)), io_base)
#define get_sda() ((inb(io_base + 1) & 0x40) ? 0 : 1)
#define is_busy() ((inb(io_base + 1) & 0x10) ? 1 : 0)
#define i2c_ctrl(val) outb((inb(io_base + 2) & ~2) | (val ? 0 : 2), io_base + 2)
#define save_port() (portval = inb(io_base))
#define restore_port() outb(portval, io_base)
#define NEED_PORTVAL
#define NEED_RESERVE
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 3
#define CCT_TYPE SAA5243
#define I2C_TYPE BITSHIFT
#define IF_NAME "homebrew"
#endif

#ifdef IF_CT
#define set_sda(val) inb(io_base + (val ? 2 : 3))
#define set_scl(val) inb(io_base + (val ? 0 : 1))
#define get_sda() (inb(io_base + 2) & 1)
#define save_port()
#define restore_port()
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 4
#define CCT_TYPE SAA5246
#define I2C_TYPE BITSHIFT
#define IF_NAME "c't"
#endif

#ifdef IF_CTSERIAL
#define set_sda(val) outb(portval = ((portval & ~1) | ((val) ? 0 : 1)), io_base + 4)
#define set_scl(val) outb(portval = ((portval & ~2) | ((val) ? 0 : 2)), io_base + 4)
#define get_sda() ((inb(io_base + 6) & 0x80) ? 0 : 1)
#define save_port() (portval = inb(io_base + 4))
#define restore_port() outb(portval, io_base + 4)
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 8
#define CCT_TYPE SAA5246
#define I2C_TYPE BITSHIFT
#define IF_NAME "serial c't"
#endif

#ifdef IF_VTX2000
#define set_sda(val) outb(portval = ((portval & ~2) | ((val) ? 0 : 2)), io_base + 1)
#define set_scl(val) outb(portval = ((portval & ~1) | ((val) ? 0 : 1)), io_base + 1)
#define get_sda() ((inb(io_base + 1) & 8) ? 1 : 0)
#define save_port()
#define restore_port()
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 8
#define CCT_TYPE SAA5246
#define I2C_TYPE BITSHIFT
#define IF_NAME "internal VTX2000/VD3000"
#endif

#ifdef IF_VTX2000EXT
#define set_sda(val) outb(portval = ((portval & ~2) | ((val) ? 0 : 2)), io_base + 4)
#define set_scl(val) outb(portval = ((portval & ~1) | ((val) ? 0 : 1)), io_base + 4)
#define get_sda() ((inb(io_base + 6) & 0x10) ? 0 : 1)
#define save_port() (portval = inb(io_base + 4))
#define restore_port() outb(portval, io_base + 4)
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 8
#define CCT_TYPE SAA5246
#define I2C_TYPE BITSHIFT
#define IF_NAME "external VTX2000"
#endif

#ifdef IF_PCVT7000
#define set_sda(val) outb(portval = ((portval & ~1) | ((val) ? 1 : 0)), io_base)
#define set_scl(val) outb(portval = ((portval & ~2) | ((val) ? 2 : 0)), io_base)
#define get_sda() (inb(io_base) & 1)
#define save_port()
#define restore_port()
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 1
#define CCT_TYPE SAA5243
#define I2C_TYPE BITSHIFT
#define IF_NAME "ELV PC-VT 7000"
#endif

#ifdef IF_SATCOM
#define set_sda(val) outb(portval = ((portval & ~1) | ((val) ? 1 : 0)), io_base + 4)
#define set_scl(val) outb(portval = ((portval & ~2) | ((val) ? 0 : 2)), io_base + 4)
#define get_sda() ((inb(io_base + 6) & 0x80) ? 0 : 1)
#define save_port() (portval = inb(io_base + 4))
#define restore_port() outb(portval, io_base + 4)
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 8
#define CCT_TYPE SAA5246
#define I2C_TYPE BITSHIFT
#define IF_NAME "SATCOM"
#endif

#ifdef IF_MICROTEXT
#define set_sda(val) inb((io_base & ~3) | (portval = ((portval & ~1) | ((val) ? 1 : 0))))
#define set_scl(val) inb((io_base & ~3) | (portval = ((portval & ~2) | ((val) ? 2 : 0))))
#define get_sda() ((inb((io_base & ~3) | portval) & 0x80) ? 1 : 0)
#define save_port()
#define restore_port()
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 4
#define CCT_TYPE SAA5243
#define I2C_TYPE BITSHIFT
#define IF_NAME "Microtext"
#endif

#ifdef IF_PCVTX_STD
#define save_port()
#define restore_port()
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 4
#define CCT_TYPE SAA5243
#define I2C_TYPE PCF8584
#define IF_NAME "TechConsult PCVTXstandard"
#endif

#ifdef IF_PCVTX_CIRC
#define save_port()
#define restore_port()
#ifdef PCVTX_NUM_VDAUS
#define NUM_DAUS PCVTX_NUM_VDAUS
#else
#define NUM_DAUS 4
#endif
#define NUM_PORTS 4
#define CCT_TYPE SAA5249
#define I2C_TYPE PCF8584
#define IF_NAME "TechConsult PCVTXcircular"
#endif

#ifdef IF_MBLASTER
#define set_sda(val) (outb(0x18, io_base), \
    outb(portval = ((portval & ~2) | ((val) ? 2 : 0)), io_base + 1))
#define set_scl(val) (outb(0x18, io_base), \
    outb(portval = ((portval & ~1) | ((val) ? 1 : 0)), io_base + 1))
#define get_sda() (outb(0x18, io_base), ((inb(io_base + 1) & 4) ? 1 : 0))
#define save_port() (outb(0x18, io_base), portval = inb(io_base + 1))
#define restore_port() (outb(0x18, io_base), outb(portval, io_base + 1))
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 2
#define CCT_TYPE SAA5248
#define I2C_TYPE BITSHIFT
#define IF_NAME "CPS TV Movie Blaster"
#endif

#ifdef IF_PRIMETIME
#define set_sda(val) outb(portval = ((portval & ~1) | ((val) ? 1 : 0)), io_base)
#define set_scl(val) outb(portval = ((portval & ~2) | ((val) ? 2 : 0)), io_base)
#define get_sda() ((inb(io_base + 1) & 1) ? 1 : 0)
#define save_port() (portval = inb(io_base + 1))
#define restore_port() outb(portval, io_base)
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 2
#define CCT_TYPE XSTV5346
#define I2C_TYPE BITSHIFT
#define TUNER_SUPPORT
#define IF_NAME "PrimeTime"
#endif

#ifdef IF_LPT
#define set_sda(val) outb(portval = ((portval & ~0x80) | ((val) ? 0 : 0x80)), io_base)
#define set_scl(val) outb(portval = ((portval & ~1) | ((val) ? 1 : 0)), io_base)
#define get_sda() ((inb(io_base + 1) & 0x80) ? 0 : 1)
#define save_port() (portval = inb(io_base))
#define restore_port() outb(portval, io_base)
#define NEED_PORTVAL
#define NUM_DAUS 4
#define NUM_BUFS 8
#define NUM_PORTS 2
#define CCT_TYPE SAA5246
#define I2C_TYPE BITSHIFT
#define IF_NAME "parallel port (G. Sinzig)"
#endif

/* These variables are settable when loading the driver (with modutils-1.1.67 & up) */
int io_base = VTX_DEFAULT_IO_BASE;
int major = VTX_DEFAULT_MAJOR;
#if (I2C_TYPE == BITSHIFT)
#ifdef VTX_CHIPSET_IS_DAMN_SLOW
int slow_if = 1;
#else
int slow_if = 0;
#endif
#endif

char kernel_version[] = "2.2.5";

static int vtx_use_count, tuner_use_count;
static int is_searching[NUM_DAUS], disp_mode = DISPOFF, region_requested;
static const int disp_modes[8][3] = {
  { 0x46, 0x03, 0x03 }, /* DISPOFF */
  { 0x46, 0xcc, 0xcc }, /* DISPNORM */
  { 0x44, 0x0f, 0x0f }, /* DISPTRANS */
  { 0x46, 0xcc, 0x46 }, /* DISPINS */
  { 0x44, 0x03, 0x03 }, /* DISPOFF, interlaced */
  { 0x44, 0xcc, 0xcc }, /* DISPNORM, interlaced */
  { 0x44, 0x0f, 0x0f }, /* DISPTRANS, interlaced */
  { 0x44, 0xcc, 0x46 }  /* DISPINS, interlaced */

};

#ifdef NEED_PORTVAL
static int portval;
#endif

#if (I2C_TYPE == BITSHIFT)
static const int io_delay[2][3] = {
  { 3, 5, 7 },          /* Slow speed */
  { 2, 3, 5 },          /* Fast speed */

};

#endif

#ifdef TUNER_SUPPORT
static struct semaphore vtx_sem = MUTEX;
#endif

#if (CCT_TYPE == SAA5249)
#define PAGE_WAIT 30                            /* Time in jiffies between requesting page and */
                                                /* checking status bits */
#define PGBUF_EXPIRE 1500                       /* Time in jiffies to wait before retransmitting */
                                                /* page regardless of infobits */
typedef struct {
  byte_t pgbuf[VTX_VIRTUALSIZE];                /* Page-buffer */
  byte_t laststat[10];                          /* Last value of infobits for DAU */
  byte_t sregs[7];                              /* Page-request registers */
  unsigned long expire;                         /* Time when page will be expired */
  unsigned clrfound : 1;                        /* VTXIOCCLRFOUND has been called */
  unsigned stopped : 1;                         /* VTXIOCSTOPDAU has been called */

} vdau_t;

static vdau_t vdau[NUM_DAUS];                   /* Data for virtual DAUs (the 5249 only
...

read more »