/*
 * Samsung HL-R5668W HD Television RS-232 Serial Interface Driver
 * Copyright (C) 2006 Eric Gumtow
 * 
 * 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 Street, Fifth Floor
 *  Boston, MA 02110-1301, USA
 *
 * ejgumtow@yahoo.com
 * http://www.ejgumtow.com/
 */


#ifndef __Samsung_HL_R5668W_driver_pvt_h__
#define __Samsung_HL_R5668W_driver_pvt_h__


#include <sys/types.h>


typedef struct {
	int option;
	u_int8_t cmd1;
	u_int8_t cmd2;
	u_int8_t cmd3;
	int need_val;
	u_int8_t min_val;
	u_int8_t max_val;
} r5668w_cmd_template_t;

typedef struct {
	u_int8_t b1;
	u_int8_t b2;
	u_int8_t b3;
	u_int8_t val;
} r5668w_cmd_t;

typedef struct {
	u_int8_t hdr1;
	u_int8_t hdr2;
	r5668w_cmd_t cmd;
	u_int8_t cksum;
} r5668w_tx_pkt_t;

typedef struct {
	u_int8_t hdr1;
	u_int8_t hdr2;
	u_int8_t status;
} r5668w_rx_pkt_t;


static int r5668w_put_cmd(int, r5668w_cmd_t *);
static int r5668w_get_response(int);


typedef struct {
	u_int32_t port_open_errs;
	u_int32_t port_get_errs;
	u_int32_t port_set_errs;
	u_int32_t port_open_ok;
	u_int32_t port_close;
	u_int32_t wrt_cmd_errs;
	u_int32_t response_get_errs;
	u_int32_t put_cmd_ok;
	u_int32_t response_read_errs;
	u_int32_t response_hdr_errs;
	u_int32_t response_cmd_errs;
	u_int32_t response_bad_status_errs;
	u_int32_t response_ok;
	u_int32_t power_cmds;
	u_int32_t volume_cmds;
	u_int32_t mute_cmds;
	u_int32_t input_cmds;
	u_int32_t cmd_invalid;
	u_int32_t cmd_param_errs;
} r5668w_stats_t;


#define STAT(x) stats.x++

#ifdef DEBUG

/*
 * Pick the #define that works for your compiler.  I think gcc 4.0 and
 * higher like the __STRING(x) define while others prefer the #x define. 
 * Yet other compilers like neither.
 */

#define PRINT_STAT(x) printf("%-30s %10d\n", __STRING(x), stats.x);
// #define PRINT_STAT(x) printf("%-30s %10d\n", #x, stats.x);
// #define PRINT_STAT(x)
#else
#define PRINT_STAT(x) printf("You must define the symbol DEBUG.\n");
#endif


#endif
