コード例 #1
0
ファイル: pt3_mx.c プロジェクト: m-tsudo/pt3
static void
mx_tuner_rftune(PT3_MX *mx, PT3_BUS *bus, __u32 freq)
{
	__u8 data[100];
	__u32 size;

	size = 0;
	mx->freq = freq;

	mx_rftune(data, &size, freq);

	if (size != 20) {
		PT3_PRINTK(0, KERN_ERR, "fail mx_rftune size = %d\n", size);
		return;
	}

	mx_write(mx, bus, data, 14);

	schedule_timeout_interruptible(msecs_to_jiffies(1));	

	mx_write(mx, bus, data + 14, 6);

	schedule_timeout_interruptible(msecs_to_jiffies(1));	
	schedule_timeout_interruptible(msecs_to_jiffies(30));	

	mx_set_register(mx, bus, 0x1a, 0x0d);

	mx_idac_setting(mx, bus);
}
コード例 #2
0
ファイル: pt3_mx.c プロジェクト: m-tsudo/pt3
STATUS
pt3_mx_set_frequency(PT3_MX *mx, __u32 channel, __s32 offset)
{
	STATUS status;
	int catv, locked1, locked2;
	__u32 number, freq;
	__u32 real_freq;
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
	struct timeval begin, now;
#else
	struct timespec64 begin, now;
#endif

	status = pt3_tc_set_agc_t(mx->tc, NULL, PT3_TC_AGC_MANUAL);
	if (status)
		return status;
	
	pt3_mx_get_channel_frequency(mx, channel, &catv, &number, &freq);

	//real_freq = (7 * freq + 1 + offset) * 1000000.0 /7.0;
	real_freq = REAL_TABLE[channel];

	mx_set_frequency(mx, NULL, real_freq);

#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
	do_gettimeofday(&begin);
#else
	ktime_get_real_ts64(&begin);
#endif
	locked1 = locked2 = 0;
	while (1) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)
		do_gettimeofday(&now);
#else
		ktime_get_real_ts64(&now);
#endif
		pt3_mx_get_locked1(mx, NULL, &locked1);
		pt3_mx_get_locked2(mx, NULL, &locked2);

		if (locked1 && locked2)
			break;
		if (time_diff(&begin, &now) > 1000)
			break;

		schedule_timeout_interruptible(msecs_to_jiffies(1));	
	}
#if 0
	PT3_PRINTK(7, KERN_DEBUG, "mx_get_locked1 %d locked2 %d\n", locked1, locked2);
#endif
	if (!(locked1 && locked2))
		return STATUS_PLL_LOCK_TIMEOUT_ERROR;
	
	status = pt3_tc_set_agc_t(mx->tc, NULL, PT3_TC_AGC_AUTO);
	if (status)
		return status;

	return status;
}
コード例 #3
0
ファイル: pt3_qm.c プロジェクト: knight-rider/ptx
static STATUS
qm_read(PT3_QM *qm, PT3_BUS *bus, __u8 addr, __u8 *data)
{
	STATUS status;
	if ((addr == 0x00 ) || (addr == 0x0d)) {
		status = pt3_tc_read_tuner(qm->tc, bus, addr, data, 1);
#if 0
		if (!bus)
			PT3_PRINTK(7, KERN_DEBUG, "qm_read addr=0x%02x data=0x%02x\n", addr, *data);
#endif
	} else 
		status = STATUS_OK;

	return status;
}
コード例 #4
0
ファイル: pt3_qm.c プロジェクト: knight-rider/ptx
STATUS
pt3_qm_set_frequency(PT3_QM *qm, __u32 channel, __s32 offset)
{
	STATUS status;
	int bs, locked;
	__u32 number, freq, freq_khz;
	struct timeval begin, now;

	status = pt3_tc_set_agc_s(qm->tc, NULL, PT3_TC_AGC_MANUAL);
	if (status)
		return status;
	
	pt3_qm_get_channel_freq(channel, &bs, &number, &freq);
	freq_khz = freq * 10 + offset;
	if (pt3_tc_index(qm->tc) == 0)
		freq_khz -= 500;
	else
		freq_khz += 500;
	qm->param.channel_freq = freq_khz;

PT3_PRINTK(7, KERN_DEBUG, "ch %d slot %d frequency %d Khz\n", channel, offset, freq_khz);

	if ((status = qm_local_lpf_tuning(qm, NULL, 1, channel)))
		return status;

	do_gettimeofday(&begin);
	while (1) {
		do_gettimeofday(&now);

		if ((status = pt3_qm_get_locked(qm, NULL, &locked)))
			return status;
		if (locked)
			break;
		if (time_diff(&begin, &now) >= 100)
			break;

		schedule_timeout_interruptible(msecs_to_jiffies(1));	
	}
	// PT3_PRINTK(7, KERN_DEBUG "qm_get_locked %d status=0x%x\n", locked, status);
	if (!locked)
		return STATUS_PLL_LOCK_TIMEOUT_ERROR;
	
	if(!(status = pt3_tc_set_agc_s(qm->tc, NULL, PT3_TC_AGC_AUTO))) {
		qm->channel = channel;
		qm->offset = offset;
	}
	return status;
}