Add support for v1.6 pcb with PCM1862.

This commit is contained in:
marqs 2017-06-05 00:02:01 +03:00
parent 2aee3294e3
commit cabc04b3b0
12 changed files with 1320 additions and 1147 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<CodeLite_Project Name="ossc_sw" InternalType="">
<CodeLite_Project Name="ossc_sw" InternalType="" Version="10.0.0">
<Plugins>
<Plugin Name="qmake">
<![CDATA[00020001N0005Debug0000000000000001N0007Release000000000000]]>
@ -26,6 +26,15 @@
}]]]>
</Plugin>
</Plugins>
<Reconciliation>
<Regexes/>
<Excludepaths/>
<Ignorefiles/>
<Extensions>
<![CDATA[cpp;c;h;hpp;xrc;wxcp;fbp]]>
</Extensions>
<Topleveldir>../software</Topleveldir>
</Reconciliation>
<VirtualDirectory Name="sys_controller">
<VirtualDirectory Name="ths7353">
<File Name="sys_controller/ths7353/ths7353.h"/>
@ -86,6 +95,11 @@
<File Name="sys_controller/ulibSD/spi_io.h"/>
<File Name="sys_controller/ulibSD/spi_io.c"/>
</VirtualDirectory>
<VirtualDirectory Name="pcm1862">
<File Name="sys_controller/pcm1862/pcm1862.c"/>
<File Name="sys_controller/pcm1862/pcm1862.h"/>
<File Name="sys_controller/pcm1862/pcm1862_regs.h"/>
</VirtualDirectory>
</VirtualDirectory>
<Description/>
<Dependencies/>
@ -161,11 +175,11 @@
<PostBuild/>
<CustomBuild Enabled="yes">
<Target Name="compile_image_jp">make clean &amp;&amp; iconv -f UTF-8 -t SHIFT-JIS ossc/menu.c &gt; ossc/menu_sjis.c &amp;&amp; make OSDLANG=JP mem_init_generate</Target>
<Target Name="compile_image_aud_jp">make clean &amp;&amp; iconv -f UTF-8 -t SHIFT-JIS ossc/menu.c &gt; ossc/menu_sjis.c &amp;&amp; make DIY_AUDIO=y OSDLANG=JP mem_init_generate</Target>
<Target Name="compile_image_aud">make clean &amp;&amp; make DIY_AUDIO=y mem_init_generate</Target>
<Target Name="compile_image_aud_jp">make clean &amp;&amp; iconv -f UTF-8 -t SHIFT-JIS ossc/menu.c &gt; ossc/menu_sjis.c &amp;&amp; make ENABLE_AUDIO=y OSDLANG=JP mem_init_generate</Target>
<Target Name="compile_image_aud">make clean &amp;&amp; make ENABLE_AUDIO=y mem_init_generate</Target>
<Target Name="compile_image">make clean &amp;&amp; make mem_init_generate</Target>
<Target Name="Build_jp">iconv -f UTF-8 -t SHIFT-JIS ossc/menu.c &gt; ossc/menu_sjis.c &amp;&amp; make OSDLANG=JP</Target>
<Target Name="Build_diy-audio">make DIY_AUDIO=y</Target>
<Target Name="Build_audio">make ENABLE_AUDIO=y</Target>
<RebuildCommand/>
<CleanCommand>make clean</CleanCommand>
<BuildCommand>make</BuildCommand>

View File

@ -151,6 +151,7 @@ C_SRCS += it6613/it6613_sys.c
C_SRCS += tvp7002/tvp7002.c
C_SRCS += tvp7002/video_modes.c
C_SRCS += ths7353/ths7353.c
C_SRCS += pcm1862/pcm1862.c
C_SRCS += spi_charlcd/lcd.c
C_SRCS += memory/flash.c
C_SRCS += memory/sdcard.c
@ -184,8 +185,8 @@ CREATE_LINKER_MAP := 1
# Common arguments for ALT_CFLAGSs
APP_CFLAGS_DEFINED_SYMBOLS := -DNO_I2C_DEBUG -DNO_DEBUG
ifeq ($(DIY_AUDIO),y)
APP_CFLAGS_DEFINED_SYMBOLS += -DDIY_AUDIO
ifeq ($(ENABLE_AUDIO),y)
APP_CFLAGS_DEFINED_SYMBOLS += -DENABLE_AUDIO
endif
ifeq ($(OSDLANG),JP)
APP_CFLAGS_DEFINED_SYMBOLS += -DOSDLANG_JP
@ -212,6 +213,7 @@ BSP_ROOT_DIR := ../sys_controller_bsp/
APP_INCLUDE_DIRS += it6613
APP_INCLUDE_DIRS += tvp7002
APP_INCLUDE_DIRS += ths7353
APP_INCLUDE_DIRS += pcm1862
APP_INCLUDE_DIRS += spi_charlcd
APP_INCLUDE_DIRS += memory
APP_INCLUDE_DIRS += ulibSD

File diff suppressed because it is too large Load Diff

View File

@ -26,6 +26,7 @@
#include "av_controller.h"
#include "tvp7002.h"
#include "ths7353.h"
#include "pcm1862.h"
#include "video_modes.h"
#include "lcd.h"
#include "flash.h"
@ -75,6 +76,11 @@ char row1[LCD_ROW_LEN+1], row2[LCD_ROW_LEN+1], menu_row1[LCD_ROW_LEN+1], menu_ro
extern alt_u8 menu_active;
avinput_t target_mode;
#ifdef ENABLE_AUDIO
alt_u8 pcm1862_active;
#endif
inline void lcd_write_menu()
{
lcd_write((char*)&menu_row1, (char*)&menu_row2);
@ -84,7 +90,7 @@ inline void lcd_write_status() {
lcd_write((char*)&row1, (char*)&row2);
}
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
inline void SetupAudio(tx_mode_t mode)
{
// shut down audio-tx before setting new config (recommended for changing audio-tx config)
@ -128,7 +134,7 @@ inline void TX_enable(tx_mode_t mode)
cm.cc.hdmi_itc = tc.hdmi_itc;
}
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
SetupAudio(mode);
#endif
@ -333,7 +339,7 @@ status_t get_status(tvp_input_t input, video_format format)
if (!memcmp(&tc.col, &cm.cc.col, sizeof(color_setup_t)))
tvp_set_fine_gain_offset(&cm.cc.col);
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
if ((tc.audio_dw_sampl != cm.cc.audio_dw_sampl) ||
#ifdef MANUAL_CTS
(tc.edtv_l2x != cm.cc.edtv_l2x) ||
@ -525,7 +531,7 @@ void program_mode()
TX_enable(cm.cc.tx_mode);
} else if (cm.cc.tx_mode==TX_HDMI) {
HDMITX_SetAVIInfoFrame(HDMI_Unkown, 0, 0, cm.cc.hdmi_itc, cm.hdmitx_pixr_ifr ? cm.tx_pixelrep : 0);
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
#ifdef MANUAL_CTS
SetupAudio(cm.cc.tx_mode);
#endif
@ -682,6 +688,13 @@ int init_hw()
InitIT6613();
#ifdef ENABLE_AUDIO
if (pcm1862_init()) {
printf("PCM1862 found\n");
pcm1862_active = 1;
}
#endif
if (check_flash() != 0) {
printf("Error: incorrect flash type detected\n");
return -1;
@ -836,8 +849,10 @@ int main()
cm.sync_active = 0;
ths_source_sel(target_ths, (cm.cc.video_lpf > 1) ? (VIDEO_LPF_MAX-cm.cc.video_lpf) : THS_LPF_BYPASS);
tvp_disable_output();
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
DisableAudioOutput();
if (pcm1862_active)
pcm_source_sel(target_input);
#endif
tvp_source_sel(target_input, target_format);
cm.clkcnt = 0; //TODO: proper invalidate

View File

@ -54,7 +54,7 @@ const avconfig_t tc_default = {
.sync_lpf = DEFAULT_SYNC_LPF,
.pre_coast = DEFAULT_PRE_COAST,
.post_coast = DEFAULT_POST_COAST,
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
.audio_dw_sampl = DEFAULT_ON,
.tx_mode = TX_HDMI,
#endif
@ -71,7 +71,7 @@ const avconfig_t tc_default = {
int set_default_avconfig()
{
memcpy(&tc, &tc_default, sizeof(avconfig_t));
#ifndef DIY_AUDIO
#ifndef ENABLE_AUDIO
tc.tx_mode = !!(IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & HDMITX_MODE_MASK);
#endif

View File

@ -76,7 +76,7 @@ typedef struct {
alt_u8 post_coast;
alt_u8 full_tx_setup;
alt_u8 vga_ilace_fix;
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
alt_u8 audio_dw_sampl;
alt_u8 audio_swap_lr;
#endif

View File

@ -26,7 +26,7 @@
#define FW_VER_MAJOR 0
#define FW_VER_MINOR 77
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
#define FW_SUFFIX1 "a"
#else
#define FW_SUFFIX1 ""

View File

@ -140,7 +140,7 @@ MENU(menu_compatibility, P99_PROTECT({ \
{ "AV3 interlacefix", OPT_AVCONFIG_SELECTION, { .sel = { &tc.vga_ilace_fix, OPT_WRAP, SETTING_ITEM(off_on_desc) } } },
}))
#ifdef DIY_AUDIO
#ifdef ENABLE_AUDIO
MENU(menu_audio, P99_PROTECT({ \
{ LNG("Down-sampling","ダウンサンプリング"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.audio_dw_sampl, OPT_WRAP, SETTING_ITEM(audio_dw_sampl_desc) } } },
{ LNG("Swap left/right","ヒダリ/ミギスワップ"), OPT_AVCONFIG_SELECTION, { .sel = { &tc.audio_swap_lr, OPT_WRAP, SETTING_ITEM(off_on_desc) } } },

View File

@ -0,0 +1,60 @@
//
// Copyright (C) 2017 Markus Hiienkari <mhiienka@niksula.hut.fi>
//
// This file is part of Open Source Scan Converter project.
//
// 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 3 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, see <http://www.gnu.org/licenses/>.
//
#include <stdio.h>
#include <unistd.h>
#include "system.h"
#include "i2c_opencores.h"
#include "pcm1862.h"
inline alt_u32 pcm1862_readreg(alt_u8 regaddr)
{
//Phase 1
I2C_start(I2CA_BASE, PCM1862_BASE, 0);
I2C_write(I2CA_BASE, regaddr, 0);
//Phase 2
I2C_start(I2CA_BASE, PCM1862_BASE, 1);
return I2C_read(I2CA_BASE,1);
}
inline void pcm1862_writereg(alt_u8 regaddr, alt_u8 data)
{
I2C_start(I2CA_BASE, PCM1862_BASE, 0);
I2C_write(I2CA_BASE, regaddr, 0);
I2C_write(I2CA_BASE, data, 1);
}
void pcm_source_sel(tvp_input_t input) {
alt_u8 adc_ch = 1<<(3-input);
pcm1862_writereg(PCM1862_ADC1L, adc_ch);
pcm1862_writereg(PCM1862_ADC1R, adc_ch);
}
int pcm1862_init()
{
if (pcm1862_readreg(0x05) != 0x86)
return 0;
//pcm1862_writereg(0x00, 0xff);
pcm1862_writereg(PCM1862_CLKCONFIG, 0x90);
return 1;
}

View File

@ -0,0 +1,31 @@
//
// Copyright (C) 2017 Markus Hiienkari <mhiienka@niksula.hut.fi>
//
// This file is part of Open Source Scan Converter project.
//
// 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 3 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, see <http://www.gnu.org/licenses/>.
//
#ifndef PCM1862_H_
#define PCM1862_H_
#include "pcm1862_regs.h"
#include "sysconfig.h"
#include "tvp7002.h"
void pcm_source_sel(tvp_input_t input) ;
int pcm1862_init();
#endif /* PCM1862_H_ */

View File

@ -0,0 +1,51 @@
//
// Copyright (C) 2017 Markus Hiienkari <mhiienka@niksula.hut.fi>
//
// This file is part of Open Source Scan Converter project.
//
// 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 3 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, see <http://www.gnu.org/licenses/>.
//
#ifndef PCM1862_REGS_H_
#define PCM1862_REGS_H_
#define PCM1862_BASE (0x94>>1)
#define PCM1862_PAGESEL 0x00
#define PCM1862_PGA1L 0x01
#define PCM1862_PGA1R 0x02
#define PCM1862_PGA2L 0x03
#define PCM1862_PGA2R 0x04
#define PCM1862_PGACONFIG 0x05
#define PCM1862_ADC1L 0x06
#define PCM1862_ADC1R 0x07
#define PCM1862_ADC2L 0x08
#define PCM1862_ADC2R 0x09
#define PCM1862_ADC2CONFIG 0x0A
#define PCM1862_PCMFMT 0x0B
#define PCM1862_TDMFMT 0x0C
#define PCM1862_TXTDM_OFFSET 0x0D
#define PCM1862_RXTDM_OFFSET 0x0E
#define PCM1862_DPGA1_GAIN_L 0x0F
#define PCM1862_DPGA1_GAIN_R 0x16
#define PCM1862_DPGA2_GAIN_L 0x17
#define PCM1862_DPGA2_GAIN_R 0x18
#define PCM1862_DPGA_CONFIG 0x19
#define PCM1862_DMIC_CONFIG 0x1A
#define PCM1862_DIN_RESAMPLE 0x1B
#define PCM1862_CLKCONFIG 0x20
#endif /* PCM1862_REGS_H_ */

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<EnsembleReport name="sys" kind="sys" version="1.0" fabric="QSYS">
<!-- Format version 17.0 595 (Future versions may contain additional information.) -->
<!-- 2017.05.30.19:34:13 -->
<!-- 2017.06.04.17:48:20 -->
<!-- A collection of modules and connections -->
<parameter name="AUTO_GENERATION_ID">
<type>java.lang.Integer</type>
<value>1496162053</value>
<value>1496587699</value>
<derived>false</derived>
<enabled>true</enabled>
<visible>false</visible>