/* * Copyright (C) 2005-2006 Micronas USA Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * 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. */ #include #include #include #include #include #include #include #include #include #define TW2804_REG_AUTOGAIN 0x02 #define TW2804_REG_HUE 0x0f #define TW2804_REG_SATURATION 0x10 #define TW2804_REG_CONTRAST 0x11 #define TW2804_REG_BRIGHTNESS 0x12 #define TW2804_REG_COLOR_KILLER 0x14 #define TW2804_REG_GAIN 0x3c #define TW2804_REG_CHROMA_GAIN 0x3d #define TW2804_REG_BLUE_BALANCE 0x3e #define TW2804_REG_RED_BALANCE 0x3f struct tw2804 { struct v4l2_subdev sd; struct v4l2_ctrl_handler hdl; u8 channel:2; u8 input:1; int norm; }; static const u8 global_registers[] = { 0x39, 0x00, 0x3a, 0xff, 0x3b, 0x84, 0x3c, 0x80, 0x3d, 0x80, 0x3e, 0x82, 0x3f, 0x82, 0x78, 0x00, 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ }; static const u8 channel_registers[] = { 0x01, 0xc4, 0x02, 0xa5, 0x03, 0x20, 0x04, 0xd0, 0x05, 0x20, 0x06, 0xd0, 0x07, 0x88, 0x08, 0x20, 0x09, 0x07, 0x0a, 0xf0, 0x0b, 0x07, 0x0c, 0xf0, 0x0d, 0x40, 0x0e, 0xd2, 0x0f, 0x80, 0x10, 0x80, 0x11, 0x80, 0x12, 0x80, 0x13, 0x1f, 0x14, 0x00, 0x15, 0x00, 0x16, 0x00, 0x17, 0x00, 0x18, 0xff, 0x19, 0xff, 0x1a, 0xff, 0x1b, 0xff, 0x1c, 0xff, 0x1d, 0xff, 0x1e, 0xff, 0x1f, 0xff, 0x20, 0x07, 0x21, 0x07, 0x22, 0x00, 0x23, 0x91, 0x24, 0x51, 0x25, 0x03, 0x26, 0x00, 0x27, 0x00, 0x28, 0x00, 0x29, 0x00, 0x2a, 0x00, 0x2b, 0x00, 0x2c, 0x00, 0x2d, 0x00, 0x2e, 0x00, 0x2f, 0x00, 0x30, 0x00, 0x31, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 0x35, 0x00, 0x36, 0x00, 0x37, 0x00, 0xff, 0xff, /* Terminator (reg 0xff does not exist) */ }; static int write_reg(struct i2c_client *client, u8 reg, u8 value, u8 channel) { return i2c_smbus_write_byte_data(client, reg | (channel << 6), value); } static int write_regs(struct i2c_client *client, const u8 *regs, u8 channel) { int ret; int i; for (i = 0; regs[i] != 0xff; i += 2) { ret = i2c_smbus_write_byte_data(client, regs[i] | (channel << 6), regs[i + 1]); if (ret < 0) return ret; } return 0; } static int read_reg(struct i2c_client *client, u8 reg, u8 channel) { return i2c_smbus_read_byte_data(client, (reg) | (channel << 6)); } static inline struct tw2804 *to_state(struct v4l2_subdev *sd) { return container_of(sd, struct tw2804, sd); } static inline struct tw2804 *to_state_from_ctrl(struct v4l2_ctrl *ctrl) { return container_of(ctrl->handler, struct tw2804, hdl); } static int tw2804_log_status(struct v4l2_subdev *sd) { struct tw2804 *state = to_state(sd); v4l2_info(sd, "Standard: %s\n", state->norm & V4L2_STD_525_60 ? "60 Hz" : "50 Hz"); v4l2_info(sd, "Channel: %d\n", state->channel); v4l2_info(sd, "Input: %d\n", state->input); return v4l2_ctrl_subdev_log_status(sd); } /* * These volatile controls are needed because all four channels share * these controls. So a change made to them through one channel would * require another channel to be updated. * * Normally this would have been done in a different way, but since the one * board that uses this driver sees this single chip as if it was on four * different i2c adapters (each adapter belonging to a separate instance of * the same USB driver) there is no reliable method that I have found to let * the instances know about each other. * * So implementing these global registers as volatile is the best we can do. */ static int tw2804_g_volatile_ctrl(struct v4l2_ctrl *ctrl) { struct tw2804 *state = to_state_from_ctrl(ctrl); struct i2c_client *client = v4l2_get_subdevdata(&state->sd); switch (ctrl->id) { case V4L2_CID_GAIN: ctrl->val = read_reg(client, TW2804_REG_GAIN, 0); return 0; case V4L2_CID_CHROMA_GAIN: ctrl->val = read_reg(client, TW2804_REG_CHROMA_GAIN, 0); return 0; case V4L2_CID_BLUE_BALANCE: ctrl->val = read_reg(client, TW2804_REG_BLUE_BALANCE, 0); return 0; case V4L2_CID_RED_BALANCE: ctrl->val = read_reg(client, TW2804_REG_RED_BALANCE, 0); return 0; } return 0; } static int tw2804_s_ctrl(struct v4l2_ctrl *ctrl) { struct tw2804 *state = to_state_from_ctrl(ctrl); struct i2c_client *client = v4l2_get_subdevdata(&state->sd); int addr; int reg; switch (ctrl->id) { case V4L2_CID_AUTOGAIN: addr = TW2804_REG_AUTOGAIN; reg = read_reg
#ifndef _UAPI__SOCK_DIAG_H__
#define _UAPI__SOCK_DIAG_H__

#include <linux/types.h>

#define SOCK_DIAG_BY_FAMILY 20

struct sock_diag_req {
	__u8	sdiag_family;
	__u8	sdiag_protocol;
};

enum {
	SK_MEMINFO_RMEM_ALLOC,
	SK_MEMINFO_RCVBUF,
	SK_MEMINFO_WMEM_ALLOC,
	SK_MEMINFO_SNDBUF,
	SK_MEMINFO_FWD_ALLOC,
	SK_MEMINFO_WMEM_QUEUED,
	SK_MEMINFO_OPTMEM,
	SK_MEMINFO_BACKLOG,

	SK_MEMINFO_VARS,
};

enum