diff options
Diffstat (limited to 'src/dxr3')
-rw-r--r-- | src/dxr3/compat.c | 28 | ||||
-rw-r--r-- | src/dxr3/dxr3_decode_spu.c | 18 | ||||
-rw-r--r-- | src/dxr3/dxr3_decode_video.c | 4 | ||||
-rw-r--r-- | src/dxr3/em8300.h | 120 | ||||
-rw-r--r-- | src/dxr3/video_out_dxr3.c | 12 | ||||
-rw-r--r-- | src/dxr3/video_out_dxr3.h | 6 |
6 files changed, 158 insertions, 30 deletions
diff --git a/src/dxr3/compat.c b/src/dxr3/compat.c new file mode 100644 index 000000000..a4722f923 --- /dev/null +++ b/src/dxr3/compat.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010 the xine project + * + * This file is part of xine, a free video player. + * + * xine 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. + * + * xine 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, USA + */ + +/* For compatibility with em8300 < 0.18.0 */ +int dxr3_compat_ioctl (int fd, int rq, void *arg) +{ + int ret = ioctl (fd, rq, arg); + if (ret < 0 && errno == EINVAL || errno == ENOTTY) + ret = ioctl (fd, rq & 0xFF, arg); + return ret; +} diff --git a/src/dxr3/dxr3_decode_spu.c b/src/dxr3/dxr3_decode_spu.c index f4d6f5051..7e7aa1f1a 100644 --- a/src/dxr3/dxr3_decode_spu.c +++ b/src/dxr3/dxr3_decode_spu.c @@ -60,6 +60,8 @@ #include "video_out_dxr3.h" #include "dxr3.h" +#include "compat.c" + #define MAX_SPU_STREAMS 32 @@ -299,7 +301,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) if (buf->content[0] == 0) /* cheap endianess detection */ dxr3_swab_clut((int *)buf->content); pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); - if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPALETTE, buf->content)) + if (dxr3_spu_setpalette(this->fd_spu, buf->content)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set CLUT (%s)\n", strerror(errno)); /* remember clut, when video out places some overlay we may need to restore it */ @@ -368,7 +370,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) this->menu = 0; this->button_filter = 1; pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); - ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); + dxr3_spu_button(this->fd_spu, NULL); write(this->fd_spu, empty_spu, sizeof(empty_spu)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); } @@ -486,14 +488,14 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) vpts = this->stream->metronom->got_spu_packet(this->stream->metronom, buf->pts); llprintf(LOG_PTS, "pts = %" PRId64 " vpts = %" PRIu64 "\n", buf->pts, vpts); vpts32 = vpts; - if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPTS, &vpts32)) + if (dxr3_spu_setpts(this->fd_spu, &vpts32)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: spu setpts failed (%s)\n", strerror(errno)); } /* has video out tampered with our palette */ if (this->dxr3_vo->clut_cluttered) { - if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPALETTE, this->clut)) + if (dxr3_spu_setpalette(this->fd_spu, this->clut)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set CLUT (%s)\n", strerror(errno)); this->dxr3_vo->clut_cluttered = 0; @@ -549,7 +551,7 @@ static void dxr3_spudec_dispose(spu_decoder_t *this_gen) llprintf(LOG_SPU, "close: SPU_FD = %i\n",this->fd_spu); pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); /* clear any remaining spu */ - ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); + dxr3_spu_button(this->fd_spu, NULL); write(this->fd_spu, empty_spu, sizeof(empty_spu)); close(this->fd_spu); this->fd_spu = 0; @@ -586,7 +588,7 @@ static void dxr3_spudec_set_button(spu_decoder_t *this_gen, int32_t button, int3 if (mode > 0 && !this->button_filter && (dxr3_spudec_copy_nav_to_btn(this, mode - 1, &btn ) > 0)) { pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); - if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn)) + if (dxr3_spu_button(this->fd_spu, &btn)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); @@ -617,7 +619,7 @@ static void dxr3_spudec_process_nav(dxr3_spudec_t *this) } if ((dxr3_spudec_copy_nav_to_btn(this, 0, &btn ) > 0)) { pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); - if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn)) + if (dxr3_spu_button(this->fd_spu, &btn)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); @@ -639,7 +641,7 @@ static void dxr3_spudec_process_nav(dxr3_spudec_t *this) if ((dxr3_spudec_copy_nav_to_btn(this, 0, &btn ) > 0)) { pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); - if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn)) + if (dxr3_spu_button(this->fd_spu, &btn)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); diff --git a/src/dxr3/dxr3_decode_video.c b/src/dxr3/dxr3_decode_video.c index a4e59eb11..252415850 100644 --- a/src/dxr3/dxr3_decode_video.c +++ b/src/dxr3/dxr3_decode_video.c @@ -49,6 +49,8 @@ #include "video_out_dxr3.h" #include "dxr3.h" +#include "compat.c" + /* once activated, we wait for this amount of missing pan&scan info * before disabling it again */ #define PAN_SCAN_WINDOW_SIZE 50 @@ -554,7 +556,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) (this->sync_every_frame || buf->pts)) { uint32_t vpts32 = vpts; /* update the dxr3's current pts value */ - if (ioctl(this->fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vpts32)) + if (dxr3_video_setpts(this->fd_video, &vpts32)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_video: set video pts failed (%s)\n", strerror(errno)); } diff --git a/src/dxr3/em8300.h b/src/dxr3/em8300.h index b862f1d49..f65ceb6f6 100644 --- a/src/dxr3/em8300.h +++ b/src/dxr3/em8300.h @@ -1,3 +1,32 @@ +/* + * em8300.h + * + * Copyright (C) 2000 Henrik Johansson <lhj@users.sourceforge.net> + * (C) 2000 Ze'ev Maor <zeev@users.sourceforge.net> + * (C) 2001 Rick Haines <rick@kuroyi.net> + * (C) 2001 Edward Salley <drawdeyellas@hotmail.com> + * (C) 2001 Jeremy T. Braun <jtbraun@mmit.edu> + * (C) 2001 Ralph Zimmermann <rz@ooe.net> + * (C) 2001 Daniel Chassot <Daniel.Chassot@vibro-meter.com> + * (C) 2002 Michael Hunold <michael@mihu.de> + * (C) 2002-2003 David Holm <mswitch@users.sourceforge.net> + * (C) 2003-2008 Nicolas Boullis <nboullis@debian.org> + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + #ifndef LINUX_EM8300_H #define LINUX_EM8300_H @@ -85,13 +114,13 @@ typedef struct { #define EM8300_OVERLAY_SIGNAL_WITH_VGA 2 #define EM8300_OVERLAY_VGA_ONLY 3 -#define EM8300_IOCTL_VIDEO_SETPTS 1 +#define EM8300_IOCTL_VIDEO_SETPTS _IOW('C',1,int) #define EM8300_IOCTL_VIDEO_GETSCR _IOR('C',2,unsigned) #define EM8300_IOCTL_VIDEO_SETSCR _IOW('C',2,unsigned) -#define EM8300_IOCTL_SPU_SETPTS 1 -#define EM8300_IOCTL_SPU_SETPALETTE 2 -#define EM8300_IOCTL_SPU_BUTTON 3 +#define EM8300_IOCTL_SPU_SETPTS _IOW('C',1,int) +#define EM8300_IOCTL_SPU_SETPALETTE _IOW('C',2,unsigned[16]) +#define EM8300_IOCTL_SPU_BUTTON _IOW('C',3,em8300_button_t) #define EM8300_ASPECTRATIO_4_3 0 #define EM8300_ASPECTRATIO_16_9 1 @@ -196,6 +225,25 @@ typedef struct { #define EM8300_MAJOR 121 #define EM8300_LOGNAME "em8300" +extern int major; + +#include <linux/version.h> +#include <linux/types.h> /* ulong, uint32_t */ +#include <linux/i2c.h> /* struct i2c_adapter */ +#include <linux/i2c-algo-bit.h> /* struct i2c_algo_bit_data */ +#include <linux/time.h> /* struct timeval */ +#include <linux/wait.h> /* wait_queue_head_t */ +#include <linux/list.h> /* struct list_head */ + +#if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#define snd_card_t struct snd_card +#else +#include <sound/driver.h> +#include <sound/core.h> +#include <sound/pcm.h> +#endif +#endif struct dicom_s { int luma; @@ -232,6 +280,31 @@ struct em8300_audio_s { int enable_bits; }; +struct em8300_model_config_s { + int use_bt865; + int dicom_other_pal; + int dicom_fix; + int dicom_control; + int bt865_ucode_timeout; + int activate_loopback; +}; + +struct adv717x_model_config_s { + int pixelport_16bit; + int pixelport_other_pal; + int pixeldata_adjust_ntsc; + int pixeldata_adjust_pal; +}; + +struct bt865_model_config_s { +}; + +struct em8300_config_s { + struct em8300_model_config_s model; + struct adv717x_model_config_s adv717x_model; + struct bt865_model_config_s bt865_model; +}; + struct em8300_s { char name[40]; @@ -250,12 +323,8 @@ struct em8300_s int playmode; - /* Sysfs */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46) - struct class_device classdev; - struct class_device classdev_mv; - struct class_device classdev_ma; - struct class_device classdev_sp; +#if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE) + snd_card_t *alsa_card; #endif /* Fifos */ @@ -291,6 +360,7 @@ struct em8300_s /* I2C clients */ int encoder_type; struct i2c_client *encoder; + struct i2c_client *eeprom; /* Microcode registers */ unsigned ucode_regs[MAX_UCODE_REGISTER]; @@ -318,14 +388,17 @@ struct em8300_s int audio_mode; int pcm_mode; int dsp_num; -/* */ - int dword_DB4; - unsigned char byte_D90[24]; + /* Channel status for S/PDIF */ + unsigned int channel_status_pos; + unsigned char channel_status[24]; + enum { NONE, OSS, ALSA } audio_driver_style; + struct semaphore audio_driver_style_lock; /* Video */ int video_mode; int video_playmode; int aspect_ratio; + int zoom; uint32_t video_pts; uint32_t video_lastpts; int video_ptsvalid,video_offset,video_count; @@ -375,10 +448,23 @@ struct em8300_s struct list_head memory; #endif + /* Checksum for the on-board eeprom */ + u8 *eeprom_checksum; + + int model; + + struct em8300_config_s config; + /* To support different options for different cards */ unsigned int card_nr; }; +#if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#undef snd_card_t +#endif +#endif + #define TIMEDIFF(a,b) a.tv_usec - b.tv_usec + \ 1000000 * (a.tv_sec - b.tv_sec) @@ -388,7 +474,8 @@ struct em8300_s */ /* em8300_i2c.c */ -int em8300_i2c_init(struct em8300_s *em); +int em8300_i2c_init1(struct em8300_s *em); +int em8300_i2c_init2(struct em8300_s *em); void em8300_i2c_exit(struct em8300_s *em); void em8300_clockgen_write(struct em8300_s *em, int abyte); @@ -408,7 +495,8 @@ ssize_t em8300_audio_write(struct em8300_s *em, const char * buf, int mpegaudio_command(struct em8300_s *em, int cmd); /* em8300_ucode.c */ -int em8300_ucode_upload(struct em8300_s *em, void *ucode_user, int ucode_size); +void em8300_ucode_upload(struct em8300_s *em, void *ucode, int ucode_size); +void em8300_require_ucode(struct em8300_s *em); /* em8300_misc.c */ int em8300_setregblock(struct em8300_s *em, int offset, int val, int len); @@ -453,7 +541,7 @@ void em8300_spu_release(struct em8300_s *em); int em8300_control_ioctl(struct em8300_s *em, int cmd, unsigned long arg); int em8300_ioctl_setvideomode(struct em8300_s *em, int mode); int em8300_ioctl_setaspectratio(struct em8300_s *em, int ratio); -void em8300_ioctl_getstatus(struct em8300_s *em, char *usermsg); +int em8300_ioctl_getstatus(struct em8300_s *em, char *usermsg); int em8300_ioctl_init(struct em8300_s *em, em8300_microcode_t *useruc); void em8300_ioctl_enable_videoout(struct em8300_s *em, int mode); int em8300_ioctl_setplaymode(struct em8300_s *em, int mode); diff --git a/src/dxr3/video_out_dxr3.c b/src/dxr3/video_out_dxr3.c index b6fa0c0ef..233453738 100644 --- a/src/dxr3/video_out_dxr3.c +++ b/src/dxr3/video_out_dxr3.c @@ -72,6 +72,8 @@ # include <libavutil/mem.h> #endif +#include "compat.c" + /* the amount of extra time we give the card for decoding */ #define DECODE_PIPE_PREBUFFER 10000 @@ -847,7 +849,7 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) 0x00, 0x01, 0x06, 0x00, 0x04, 0x00, 0x07, 0xFF, 0x00, 0x01, 0x00, 0x20, 0x02, 0xFF }; /* just clear any previous spu */ - ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); + dxr3_spu_button(this->fd_spu, NULL); write(this->fd_spu, empty_spu, sizeof(empty_spu)); pthread_mutex_unlock(&this->spu_device_lock); return; @@ -859,7 +861,7 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) this->spu_enc->color[6] = this->spu_enc->hili_color[2]; this->spu_enc->color[7] = this->spu_enc->hili_color[3]; /* set palette */ - if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPALETTE, this->spu_enc->color)) + if (dxr3_spu_setpalette(this->fd_spu, this->spu_enc->color)) xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: failed to set CLUT (%s)\n", strerror(errno)); this->clut_cluttered = 1; @@ -882,7 +884,7 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) btn.right = this->spu_enc->overlay->x + this->spu_enc->overlay->hili_right - 1; btn.top = this->spu_enc->overlay->y + this->spu_enc->overlay->hili_top; btn.bottom = this->spu_enc->overlay->y + this->spu_enc->overlay->hili_bottom - 2; - if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn)) + if (dxr3_spu_button(this->fd_spu, &btn)) xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); @@ -972,7 +974,7 @@ static void dxr3_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) } /* inform the card on the timing */ - if (ioctl(this->fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vpts32)) + if (dxr3_video_setpts(this->fd_video, &vpts32)) xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: set video pts failed (%s)\n", strerror(errno)); /* for non-mpeg, the encoder plugin is responsible for calling @@ -1227,7 +1229,7 @@ static void dxr3_dispose(vo_driver_t *this_gen) 0x00, 0x01, 0x06, 0x00, 0x04, 0x00, 0x07, 0xFF, 0x00, 0x01, 0x00, 0x20, 0x02, 0xFF }; /* clear any remaining spu */ - ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); + dxr3_spu_button(this->fd_spu, NULL); write(this->fd_spu, empty_spu, sizeof(empty_spu)); close(this->fd_spu); } diff --git a/src/dxr3/video_out_dxr3.h b/src/dxr3/video_out_dxr3.h index f120c435d..6faabc00f 100644 --- a/src/dxr3/video_out_dxr3.h +++ b/src/dxr3/video_out_dxr3.h @@ -174,3 +174,9 @@ int dxr3_lavc_init(dxr3_driver_t *, plugin_node_t *); /* spu encoder functions */ spu_encoder_t *dxr3_spu_encoder_init(void); void dxr3_spu_encode(spu_encoder_t *); + +#define dxr3_video_setpts(fd,arg) dxr3_compat_ioctl((fd), EM8300_IOCTL_VIDEO_SETPTS, (arg)) +#define dxr3_spu_setpts(fd,arg) dxr3_compat_ioctl((fd), EM8300_IOCTL_SPU_SETPTS, (arg)) +#define dxr3_spu_setpalette(fd,arg) dxr3_compat_ioctl((fd), EM8300_IOCTL_SPU_SETPALETTE, (arg)) +#define dxr3_spu_button(fd,arg) dxr3_compat_ioctl((fd), EM8300_IOCTL_SPU_BUTTON, (arg)) +int dxr3_compat_ioctl (int, int, void *); |