#ifndef BOOST_MPL_AUX_PREPROCESSOR_DEF_PARAMS_TAIL_HPP_INCLUDED
#define BOOST_MPL_AUX_PREPROCESSOR_DEF_PARAMS_TAIL_HPP_INCLUDED

// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.

// $Id$
// $Date$
// $Revision$

#include <boost/mpl/limits/arity.hpp>
#include <boost/mpl/aux_/config/dtp.hpp>
#include <boost/mpl/aux_/config/preprocessor.hpp>

#include <boost/preprocessor/comma_if.hpp>
#include <boost/preprocessor/logical/and.hpp>
#include <boost/preprocessor/identity.hpp>
#include <boost/preprocessor/empty.hpp>

// BOOST_MPL_PP_DEF_PARAMS_TAIL(1,T,value): , T1 = value, .., Tn = value
// BOOST_MPL_PP_DEF_PARAMS_TAIL(2,T,value): , T2 = value, .., Tn = value
// BOOST_MPL_PP_DEF_PARAMS_TAIL(n,T,value): <nothing>

#if !defined(BOOST_MPL_CFG_NO_OWN_PP_PRIMITIVES)

#   include <boost/mpl/aux_/preprocessor/filter_params.hpp>
#   include <boost/mpl/aux_/preprocessor/sub.hpp>

#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_IMPL(i, param, value_func) \
    BOOST_MPL_PP_DEF_PARAMS_TAIL_DELAY_1( \
          i \
        , BOOST_MPL_PP_SUB(BOOST_MPL_LIMIT_METAFUNCTION_ARITY,i) \
        , param \
        , value_func \
        ) \
    /**/

#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_DELAY_1(i, n, param, value_func) \
    BOOST_MPL_PP_DEF_PARAMS_TAIL_DELAY_2(i,n,param,value_func) \
    /**/

#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_DELAY_2(i, n, param, value_func) \
    BOOST_PP_COMMA_IF(BOOST_PP_AND(i,n)) \
    BOOST_MPL_PP_DEF_PARAMS_TAIL_##i(n,param,value_func) \
    /**/

#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_0(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##1 v(),p##2 v(),p##3 v(),p##4 v(),p##5 v(),p##6 v(),p##7 v(),p##8 v(),p##9 v())
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_1(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##2 v(),p##3 v(),p##4 v(),p##5 v(),p##6 v(),p##7 v(),p##8 v(),p##9 v(),p1)
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_2(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##3 v(),p##4 v(),p##5 v(),p##6 v(),p##7 v(),p##8 v(),p##9 v(),p1,p2)
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_3(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##4 v(),p##5 v(),p##6 v(),p##7 v(),p##8 v(),p##9 v(),p1,p2,p3)
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_4(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##5 v(),p##6 v(),p##7 v(),p##8 v(),p##9 v(),p1,p2,p3,p4)
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_5(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##6 v(),p##7 v(),p##8 v(),p##9 v(),p1,p2,p3,p4,p5)
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_6(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##7 v(),p##8 v(),p##9 v(),p1,p2,p3,p4,p5,p6)
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_7(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##8 v(),p##9 v(),p1,p2,p3,p4,p5,p6,p7)
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_8(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p##9 v(),p1,p2,p3,p4,p5,p6,p7,p8)
#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_9(i,p,v) BOOST_MPL_PP_FILTER_PARAMS_##i(p1,p2,p3,p4,p5,p6,p7,p8,p9)

#else

#   include <boost/preprocessor/arithmetic/add.hpp>
#   include <boost/preprocessor/arithmetic/sub.hpp>
#   include <boost/preprocessor/inc.hpp>
#   include <boost/preprocessor/tuple/elem.hpp>
#   include <boost/preprocessor/repeat.hpp>
#   include <boost/preprocessor/cat.hpp>

#   define BOOST_MPL_PP_AUX_TAIL_PARAM_FUNC(unused, i, op) \
    , BOOST_PP_CAT( \
          BOOST_PP_TUPLE_ELEM(3, 1, op) \
        , BOOST_PP_ADD_D(1, i, BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(3, 0, op))) \
        ) BOOST_PP_TUPLE_ELEM(3, 2, op)() \
    /**/

#   define BOOST_MPL_PP_DEF_PARAMS_TAIL_IMPL(i, param, value_func) \
    BOOST_PP_REPEAT( \
          BOOST_PP_SUB_D(1, BOOST_MPL_LIMIT_METAFUNCTION_ARITY, i) \
        , BOOST_MPL_PP_AUX_TAIL_PARAM_FUNC \
        , (i, param, value_func) \
        ) \
    /**/

#endif // BOOST_MPL_CFG_NO_OWN_PP_PRIMITIVES

#define BOOST_MPL_PP_DEF_PARAMS_TAIL(i, param, value) \
    BOOST_MPL_PP_DEF_PARAMS_TAIL_IMPL(i, param, BOOST_PP_IDENTITY(=value)) \
    /**/

#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES)
#   define BOOST_MPL_PP_NESTED_DEF_PARAMS_TAIL(i, param, value) \
    BOOST_MPL_PP_DEF_PARAMS_TAIL_IMPL(i, param, BOOST_PP_IDENTITY(=value)) \
    /**/
#else
#   define BOOST_MPL_PP_NESTED_DEF_PARAMS_TAIL(i, param, value) \
    BOOST_MPL_PP_DEF_PARAMS_TAIL_IMPL(i, param, BOOST_PP_EMPTY) \
    /**/
#endif

#endif // BOOST_MPL_AUX_PREPROCESSOR_DEF_PARAMS_TAIL_HPP_INCLUDED

{'repo_name': 'danoli3/ofxiOSBoost', 'stars': '266', 'repo_language': 'C++', 'file_name': 'stack.hpp', 'mime_type': 'text/x-c', 'hash': -2987706879497655317, 'source_dataset': 'data'}


/*
 * clearpad_tm1217.c - Touch Screen driver for Synaptics Clearpad
 * TM1217 controller
 *
 * Copyright (C) 2008 Intel Corp
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 * 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; version 2 of the License.
 *
 * 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; ifnot, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 *
 * Questions/Comments/Bug fixes to Ramesh Agarwal (ramesh.agarwal@intel.com)
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/i2c.h>
#include <linux/timer.h>
#include <linux/gpio.h>
#include <linux/hrtimer.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include "cp_tm1217.h"

#define CPTM1217_DEVICE_NAME		"cptm1217"
#define CPTM1217_DRIVER_NAME		CPTM1217_DEVICE_NAME

#define MAX_TOUCH_SUPPORTED		2
#define TOUCH_SUPPORTED			1
#define SAMPLING_FREQ			80	/* Frequency in HZ */
#define DELAY_BTWIN_SAMPLE		(1000 / SAMPLING_FREQ)
#define WAIT_FOR_RESPONSE		5	/* 5msec just works */
#define MAX_RETRIES			5	/* As above */
#define INCREMENTAL_DELAY		5	/* As above */

/* Regster Definitions */
#define TMA1217_DEV_STATUS		0x13	/* Device Status */
#define TMA1217_INT_STATUS		0x14	/* Interrupt Status */

/* Controller can detect up to 2 possible finger touches.
 * Each finger touch provides  12 bit X Y co-ordinates, the values are split
 * across 2 registers, and an 8 bit  Z value */
#define TMA1217_FINGER_STATE		0x18 /* Finger State */
#define TMA1217_FINGER1_X_HIGHER8	0x19 /* Higher 8 bit of X coordinate */
#define TMA1217_FINGER1_Y_HIGHER8	0x1A /* Higher 8 bit of Y coordinate */
#define TMA1217_FINGER1_XY_LOWER4	0x1B /* Lower 4 bits of X and Y */
#define TMA1217_FINGER1_Z_VALUE		0x1D /* 8 bit Z value for finger 1 */
#define TMA1217_FINGER2_X_HIGHER8	0x1E /* Higher 8 bit of X coordinate */
#define TMA1217_FINGER2_Y_HIGHER8	0x1F /* Higher 8 bit of Y coordinate */
#define TMA1217_FINGER2_XY_LOWER4	0x20 /* Lower 4 bits of X and Y */
#define TMA1217_FINGER2_Z_VALUE		0x22 /* 8 bit Z value for finger 2 */
#define TMA1217_DEVICE_CTRL		0x23 /* Device Control */
#define TMA1217_INTERRUPT_ENABLE	0x24 /* Interrupt Enable */
#define TMA1217_REPORT_MODE		0x2B /* Reporting Mode */
#define TMA1217_MAX_X_LOWER8		0x31 /* Bit 0-7 for Max X */
#define TMA1217_MAX_X_HIGHER4		0x32 /* Bit 8-11 for Max X */
#define TMA1217_MAX_Y_LOWER8		0x33 /* Bit 0-7 for Max Y */
#define TMA1217_MAX_Y_HIGHER4		0x34 /* Bit 8-11 for Max Y */
#define TMA1217_DEVICE_CMD_RESET	0x67 /* Device CMD reg for reset */
#define TMA1217_DEVICE_CMD_REZERO	0x69 /* Device CMD reg for rezero */

#define TMA1217_MANUFACTURER_ID		0x73 /* Manufacturer Id */
#define TMA1217_PRODUCT_FAMILY		0x75 /* Product Family */
#define TMA1217_FIRMWARE_REVISION	0x76 /* Firmware Revision */
#define TMA1217_SERIAL_NO_HIGH		0x7C /* Bit 8-15 of device serial no. */
#define TMA1217_SERIAL_NO_LOW		0x7D /* Bit 0-7 of device serial no. */
#define TMA1217_PRODUCT_ID_START	0x7E /* Start address for 10 byte ID */
#define TMA1217_DEVICE_CAPABILITY	0x8B /* Reporting capability */

/*
 * The touch position structure.
 */
struct touch_state {
	int	x;
	int	y;
	bool button;
};

/* Device Specific info given by the controller */
struct cp_dev_info {
	u16	maxX;
	u16	maxY;
};

/* Vendor related info given by the controller */
struct cp_vendor_info {
	u8	vendor_id;
	u8	product_family;
	u8	firmware_rev;
	u16	serial_no;
};

/*
 * Private structure to store the device details
 */
struct cp_tm1217_device {
	struct i2c_client	*client;
	struct device		*dev;
	struct cp_vendor_info	vinfo;
	struct cp_dev_info	dinfo;
	struct input_dev_info {
		char			phys[32];
		char			name[128];
		struct input_dev	*input;
		struct touch_state	touch;
	} cp_input_info[MAX_TOUCH_SUPPORTED];

	int	thread_running;
	struct mutex	thread_mutex;

	int gpio;
};

/* The following functions are used to read/write registers on the device
 * as per the RMI prorocol. Technically, a page select should be written
 * before doing read/write but since the register offsets are below 0xFF
 * we can use the default value of page which is 0x00
 */
static int cp_tm1217_read(struct cp_tm1217_device *ts,
				u8 *req, int size)
{
	int i, retval;

	/* Send the address */
	retval = i2c_master_send(ts->client, &req[0], 1);
	if (retval != 1) {
		dev_err(ts->dev, "cp_tm1217: I2C send failed\n");
		return retval;
	}
	msleep(WAIT_FOR_RESPONSE);
	for (i = 0; i < MAX_RETRIES; i++) {
		retval = i2c_master_recv(ts->client, &req[1], size);
		if (retval == size) {
			break;
		} else {
			msleep(INCREMENTAL_DELAY);
			dev_dbg(ts->dev, "cp_tm1217: Retry count is %d\n", i);
		}
	}
	if (retval != size)
		dev_err(ts->dev, "cp_tm1217: Read from device failed\n");

	return retval;
}

static int cp_tm1217_write(struct cp_tm1217_device *ts,
				u8 *req, int size)
{
	int retval;

	/* Send the address and the data to be written */
	retval = i2c_master_send(ts->client, &req[0], size + 1);
	if (retval != size + 1) {
		dev_err(ts->dev, "cp_tm1217: I2C write  failed: %d\n", retval);
		return retval;
	}
	/* Wait for the write to complete. TBD why this is required */
	msleep(WAIT_FOR_RESPONSE);

	return size;
}

static int cp_tm1217_mask_interrupt(struct cp_tm1217_device *ts)
{
	u8 req[2];
	int retval;

	req[0] = TMA1217_INTERRUPT_ENABLE;
	req[1] = 0x0;
	retval = cp_tm1217_write(ts, req, 1);
	if (retval != 1)
		return -EIO;

	return 0;
}

static int cp_tm1217_unmask_interrupt(struct cp_tm1217_device *ts)
{
	u8 req[2];
	int retval;

	req[0] = TMA1217_INTERRUPT_ENABLE;
	req[1] = 0xa;
	retval = cp_tm1217_write(ts, req, 1);
	if (retval != 1)
		return -EIO;

	return 0;
}

static void process_touch(struct cp_tm1217_device *ts, int index)
{
	int retval;
	struct input_dev_info *input_info =
		(struct input_dev_info *)&ts->cp_input_info[index];
	u8 xy_data[6];

	if (index == 0)
		xy_data[0] = TMA1217_FINGER1_X_HIGHER8;
	else
		xy_data[0] = TMA1217_FINGER2_X_HIGHER8;

	retval = cp_tm1217_read(ts, xy_data, 5);
	if (retval < 5) {
		dev_err(ts->dev, "cp_tm1217: XY read from device failed\n");
		return;
	}

	/* Note: Currently not using the Z values but may be requried in
	   the future. */
	input_info->touch.x = (xy_data[1] << 4)
					| (xy_data[3] & 0x0F);
	input_info->touch.y = (xy_data[2] << 4)
					| ((xy_data[3] & 0xF0) >> 4);
	input_report_abs(input_info->input, ABS_X, input_info->touch.x);
	input_report_abs(input_info->input, ABS_Y, input_info->touch.y);
	input_sync(input_info->input);
}

static void cp_tm1217_get_data(struct cp_tm1217_device *ts)
{
	u8 req[2];
	int retval, i, finger_touched = 0;

	do {
		req[0] = TMA1217_FINGER_STATE;
		retval = cp_tm1217_read(ts, req, 1);
		if (retval != 1) {
			dev_err(ts->dev,
				"cp_tm1217: Read from device failed\n");
			continue;
		}
		finger_touched = 0;
		/* Start sampling until the pressure is below
		  threshold */
		for (i = 0; i < TOUCH_SUPPORTED; i++) {
			if (req[1] & 0x3) {
				finger_touched++;
				if (ts->cp_input_info[i].touch.button == 0) {
					/* send the button touch event */
					input_report_key(
						ts->cp_input_info[i].input,
						BTN_TOUCH, 1);
					ts->cp_input_info[i].touch.button = 1;
				}
				process_touch(ts, i);
			} else {
				if (ts->cp_input_info[i].touch.button == 1) {
					/* send the button release event */
					input_report_key(
						ts->cp_input_info[i].input,
						BTN_TOUCH, 0);
					input_sync(ts->cp_input_info[i].input);
					ts->cp_input_info[i].touch.button = 0;
				}
			}
			req[1] = req[1] >> 2;
		}
		msleep(DELAY_BTWIN_SAMPLE);
	} while (finger_touched > 0);
}

static irqreturn_t cp_tm1217_sample_thread(int irq, void *handle)
{
	struct cp_tm1217_device *ts = (struct cp_tm1217_device *) handle;
	u8 req[2];
	int retval;

	/* Chedk if another thread is already running */
	mutex_lock(&ts->thread_mutex);
	if (ts->thread_running == 1) {
		mutex_unlock(&ts->thread_mutex);
		return IRQ_HANDLED;
	} else {
		ts->thread_running = 1;
		mutex_unlock(&ts->thread_mutex);
	}

	/* Mask the interrupts */
	retval = cp_tm1217_mask_interrupt(ts);

	/* Read the Interrupt Status register to find the cause of the
	   Interrupt */
	req[0] = TMA1217_INT_STATUS;
	retval = cp_tm1217_read(ts, req, 1);
	if (retval != 1)
		goto exit_thread;

	if (!(req[1] & 0x8))
		goto exit_thread;

	cp_tm1217_get_data(ts);

exit_thread:
	/* Unmask the interrupts before going to sleep */
	retval = cp_tm1217_unmask_interrupt(ts);

	mutex_lock(&ts->thread_mutex);
	ts->thread_running = 0;
	mutex_unlock(&ts->thread_mutex);

	return IRQ_HANDLED;
}

static int cp_tm1217_init_data(struct cp_tm1217_device *ts)
{
	int retval;
	u8	req[2];

	/* Read the vendor id/ fw revision etc. Ignoring return check as this
	   is non critical info  */
	req[0] = TMA1217_MANUFACTURER_ID;
	retval = cp_tm1217_read(ts, req, 1);
	ts->vinfo.vendor_id = req[1];

	req[0] = TMA1217_PRODUCT_FAMILY;
	retval = cp_tm1217_read(ts, req, 1);
	ts->vinfo.product_family = req[1];

	req[0] = TMA1217_FIRMWARE_REVISION;
	retval = cp_tm1217_read(ts, req, 1);
	ts->vinfo.firmware_rev = req[1];

	req[0] = TMA1217_SERIAL_NO_HIGH;
	retval = cp_tm1217_read(ts, req, 1);
	ts->vinfo.serial_no = (req[1] << 8);

	req[0] = TMA1217_SERIAL_NO_LOW;
	retval = cp_tm1217_read(ts, req, 1);
	ts->vinfo.serial_no = ts->vinfo.serial_no | req[1];

	req[0] = TMA1217_MAX_X_HIGHER4;
	retval = cp_tm1217_read(ts, req, 1);
	ts->dinfo.maxX = (req[1] & 0xF) << 8;

	req[0] = TMA1217_MAX_X_LOWER8;
	retval = cp_tm1217_read(ts, req, 1);
	ts->dinfo.maxX = ts->dinfo.maxX | req[1];

	req[0] = TMA1217_MAX_Y_HIGHER4;
	retval = cp_tm1217_read(ts, req, 1);
	ts->dinfo.maxY = (req[1] & 0xF) << 8;

	req[0] = TMA1217_MAX_Y_LOWER8;
	retval = cp_tm1217_read(ts, req, 1);
	ts->dinfo.maxY = ts->dinfo.maxY | req[1];

	return 0;

}

/*
 *	Set up a GPIO for use as the interrupt. We can't simply do this at
 *	boot time because the GPIO drivers themselves may not be around at
 *	boot/firmware set up time to do the work. Instead defer it to driver
 *	detection.
 */

static int cp_tm1217_setup_gpio_irq(struct cp_tm1217_device *ts)
{
	int retval;

	/* Hook up the irq handler */
	retval = gpio_request(ts->gpio, "cp_tm1217_touch");
	if (retval < 0) {
		dev_err(ts->dev, "cp_tm1217: GPIO request failed error %d\n",
								retval);
		return retval;
	}

	retval = gpio_direction_input(ts->gpio);
	if (retval < 0) {
		dev_err(ts->dev,
		"cp_tm1217: GPIO direction configuration failed, error %d\n",
								retval);
		gpio_free(ts->gpio);
		return retval;
	}

	retval = gpio_to_irq(ts->gpio);
	if (retval < 0) {
		dev_err(ts->dev, "cp_tm1217: GPIO to IRQ failedi,"
		" error %d\n", retval);
		gpio_free(ts->gpio);
	}
	dev_dbg(ts->dev,
		"cp_tm1217: Got IRQ number is %d for GPIO %d\n",
		retval, ts->gpio);
	return retval;
}

static int cp_tm1217_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct cp_tm1217_device *ts;
	struct input_dev *input_dev;
	struct input_dev_info	*input_info;
	struct cp_tm1217_platform_data *pdata;
	u8 req[2];
	int i, retval;

	/* No pdata is fine - we then use "normal" IRQ mode */

	pdata = client->dev.platform_data;

	ts = kzalloc(sizeof(struct cp_tm1217_device), GFP_KERNEL);
	if (!ts) {
		dev_err(&client->dev,
			"cp_tm1217: Private Device Struct alloc failed\n");
		return -ENOMEM;
	}

	ts->client = client;
	ts->dev = &client->dev;
	i2c_set_clientdata(client, ts);

	ts->thread_running = 0;
	mutex_init(&ts->thread_mutex);

	/* Reset the Controller */
	req[0] = TMA1217_DEVICE_CMD_RESET;
	req[1] = 0x1;
	retval = cp_tm1217_write(ts, req, 1);
	if (retval != 1) {
		dev_err(ts->dev, "cp_tm1217: Controller reset failed\n");
		kfree(ts);
		return -EIO;
	}

	/* Clear up the interrupt status from reset. */
	req[0] = TMA1217_INT_STATUS;
	retval = cp_tm1217_read(ts, req, 1);

	/* Mask all the interrupts */
	retval = cp_tm1217_mask_interrupt(ts);

	/* Read the controller information */
	cp_tm1217_init_data(ts);

	/* The following code will register multiple event devices when
	   multi-pointer is enabled, the code has not been tested
	   with MPX */
	for (i = 0; i < TOUCH_SUPPORTED; i++) {
		input_dev = input_allocate_device();
		if (input_dev == NULL) {
			dev_err(ts->dev,
				"cp_tm1217:Input Device Struct alloc failed\n");
			retval = -ENOMEM;
			goto fail;
		}
		input_info = &ts->cp_input_info[i];
		snprintf(input_info->name, sizeof(input_info->name),
			"cp_tm1217_touchscreen_%d", i);
		input_dev->name = input_info->name;
		snprintf(input_info->phys, sizeof(input_info->phys),
			"%s/input%d", dev_name(&client->dev), i);

		input_dev->phys = input_info->phys;
		input_dev->id.bustype = BUS_I2C;

		input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
		input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);

		input_set_abs_params(input_dev, ABS_X, 0, ts->dinfo.maxX, 0, 0);
		input_set_abs_params(input_dev, ABS_Y, 0, ts->dinfo.maxY, 0, 0);

		retval = input_register_device(input_dev);
		if (retval) {
			dev_err(ts->dev,
				"Input dev registration failed for %s\n",
					input_dev->name);
			input_free_device(input_dev);
			goto fail;
		}
		input_info->input = input_dev;
	}

	/* Setup the reporting mode to send an interrupt only when
	   finger arrives or departs. */
	req[0] = TMA1217_REPORT_MODE;
	req[1] = 0x02;
	retval = cp_tm1217_write(ts, req, 1);

	/* Setup the device to no sleep mode for now and make it configured */
	req[0] = TMA1217_DEVICE_CTRL;
	req[1] = 0x84;
	retval = cp_tm1217_write(ts, req, 1);

	/* Check for the status of the device */
	req[0] = TMA1217_DEV_STATUS;
	retval = cp_tm1217_read(ts, req, 1);
	if (req[1] != 0) {
		dev_err(ts->dev,
			"cp_tm1217: Device Status 0x%x != 0: config failed\n",
			req[1]);

		retval = -EIO;
		goto fail;
	}

	if (pdata && pdata->gpio) {
		ts->gpio = pdata->gpio;
		retval = cp_tm1217_setup_gpio_irq(ts);
	} else
		retval = client->irq;

	if (retval < 0) {
		dev_err(ts->dev, "cp_tm1217: GPIO request failed error %d\n",
								retval);
		goto fail;
	}

	client->irq = retval;

	retval = request_threaded_irq(client->irq,
		NULL, cp_tm1217_sample_thread,
		IRQF_TRIGGER_FALLING, "cp_tm1217_touch", ts);
	if (retval < 0) {
		dev_err(ts->dev, "cp_tm1217: Request IRQ error %d\n", retval);
		goto fail_gpio;
	}

	/* Unmask the interrupts */
	retval = cp_tm1217_unmask_interrupt(ts);
	if (retval == 0)
		return 0;

	free_irq(client->irq, ts);
fail_gpio:
	if (ts->gpio)
		gpio_free(ts->gpio);
fail:
	/* Clean up before returning failure */
	for (i = 0; i < TOUCH_SUPPORTED; i++) {
		if (ts->cp_input_info[i].input) {
			input_unregister_device(ts->cp_input_info[i].input);
			input_free_device(ts->cp_input_info[i].input);
		}
	}
	kfree(ts);
	return retval;

}

/*
 * cp_tm1217 suspend
 *
 */
static int cp_tm1217_suspend(struct i2c_client *client, pm_message_t mesg)
{
	struct cp_tm1217_device *ts = i2c_get_clientdata(client);
	u8 req[2];
	int retval;

	/* Put the controller to sleep */
	req[0] = TMA1217_DEVICE_CTRL;
	retval = cp_tm1217_read(ts, req, 1);
	req[1] = (req[1] & 0xF8) | 0x1;
	retval = cp_tm1217_write(ts, req, 1);

	if (device_may_wakeup(&client->dev))
		enable_irq_wake(client->irq);

	return 0;
}

/*
 * cp_tm1217_resume
 *
 */
static int cp_tm1217_resume(struct i2c_client *client)
{
	struct cp_tm1217_device *ts = i2c_get_clientdata(client);
	u8 req[2];
	int retval;

	/* Take the controller out of sleep */
	req[0] = TMA1217_DEVICE_CTRL;
	retval = cp_tm1217_read(ts, req, 1);
	req[1] = (req[1] & 0xF8) | 0x4;
	retval = cp_tm1217_write(ts, req, 1);

	/* Restore the register settings sinc the power to the
	   could have been cut off */

	/* Setup the reporting mode to send an interrupt only when
	   finger arrives or departs. */
	req[0] = TMA1217_REPORT_MODE;
	req[1] = 0x02;
	retval = cp_tm1217_write(ts, req, 1);

	/* Setup the device to no sleep mode for now and make it configured */
	req[0] = TMA1217_DEVICE_CTRL;
	req[1] = 0x84;
	retval = cp_tm1217_write(ts, req, 1);

	/* Setup the interrupt mask */
	retval = cp_tm1217_unmask_interrupt(ts);

	if (device_may_wakeup(&client->dev))
		disable_irq_wake(client->irq);

	return 0;
}

/*
 * cp_tm1217_remove
 *
 */
static int cp_tm1217_remove(struct i2c_client *client)
{
	struct cp_tm1217_device *ts = i2c_get_clientdata(client);
	int i;

	free_irq(client->irq, ts);
	if (ts->gpio)
		gpio_free(ts->gpio);
	for (i = 0; i < TOUCH_SUPPORTED; i++)
		input_unregister_device(ts->cp_input_info[i].input);
	kfree(ts);
	return 0;
}

static struct i2c_device_id cp_tm1217_idtable[] = {
	{ CPTM1217_DEVICE_NAME, 0 },
	{ }
};

MODULE_DEVICE_TABLE(i2c, cp_tm1217_idtable);

static struct i2c_driver cp_tm1217_driver = {
	.driver = {
		.owner	= THIS_MODULE,
		.name	= CPTM1217_DRIVER_NAME,
	},
	.id_table	= cp_tm1217_idtable,
	.probe		= cp_tm1217_probe,
	.remove		= cp_tm1217_remove,
	.suspend    = cp_tm1217_suspend,
	.resume     = cp_tm1217_resume,
};

static int __init clearpad_tm1217_init(void)
{
	return i2c_add_driver(&cp_tm1217_driver);
}

static void __exit clearpad_tm1217_exit(void)
{
	i2c_del_driver(&cp_tm1217_driver);
}

module_init(clearpad_tm1217_init);
module_exit(clearpad_tm1217_exit);

MODULE_AUTHOR("Ramesh Agarwal <ramesh.agarwal@intel.com>");
MODULE_DESCRIPTION("Synaptics TM1217 TouchScreen Driver");
MODULE_LICENSE("GPL v2");

{'repo_name': 'tangsilian/android-vuln', 'stars': '315', 'repo_language': 'C', 'file_name': 'bamboo_defconfig', 'mime_type': 'text/plain', 'hash': 3139302357652267960, 'source_dataset': 'data'}


$(function(){
    $('.body-div').on('click','.btn',btnClick);
    $('.body-div').on('click','.layer',hideLayer);

    function btnClick(){
        // $('.layer').show();
        alert('我是按钮')
    }

    function hideLayer(){
        // $('.layer').hide();
        alert('我是弹层')
    }
});

/**
 * @file nishi
 * @date 2018/03/23
 * @author houzhiqiang@sogou-inc.com
 */

{'repo_name': 'zhiqiang21/blog', 'stars': '374', 'repo_language': 'JavaScript', 'file_name': '2016年年终总结----拒绝平庸的一年_20170202.md', 'mime_type': 'text/plain', 'hash': 5799724254836726200, 'source_dataset': 'data'}


edmundrichardson.com.   3600    IN      SOA     42dbc308.dsl.aros.net. drr.aros.net. 2003070707 3600 28800 2419200 3600
edmundrichardson.com.   3600    IN      NS      ns0.xname.org.
edmundrichardson.com.   3600    IN      NS      ns1.xname.org.
edmundrichardson.com.   3600    IN      SOA     42dbc308.dsl.aros.net. drr.aros.net. 2003070707 3600 28800 2419200 3600

{'repo_name': 'NLnetLabs/nsd', 'stars': '150', 'repo_language': 'C', 'file_name': 'CREDITS', 'mime_type': 'text/plain', 'hash': -227304570608014769, 'source_dataset': 'data'}


// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

    using System;
    using System.Collections;

    using NUnit.Framework;
    using System.IO;

    using Microsoft.Build.BuildEngine;
    using System.Threading;
    using System.Reflection;

    namespace Microsoft.Build.UnitTests
    {
        [TestFixture]
        public class PropertyGroupTests
        {
            ///
            ///
            /// <owner>SumedhK</owner>
            [Test]
            public void ImportOutputProperties()
            {
                BuildPropertyGroup pg = new BuildPropertyGroup();
                pg.SetProperty("foo", "fooval");
                pg.SetProperty(new BuildProperty("bar", "barval", PropertyType.EnvironmentProperty));
                pg.SetProperty(new BuildProperty("baz", "bazval", PropertyType.GlobalProperty));
                pg.SetProperty(new BuildProperty("caz", "cazval", PropertyType.ImportedProperty));
                pg.SetProperty(new BuildProperty("barb", "barbval", PropertyType.OutputProperty));

                BuildPropertyGroup pgo = new BuildPropertyGroup();
                pgo.SetProperty(new BuildProperty("foo", "fooout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("bar", "barout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("baz", "bazout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("caz", "cazout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("barb", "barbout", PropertyType.OutputProperty));
                pgo.SetProperty(new BuildProperty("gaz", "gazout", PropertyType.OutputProperty));

                pg.ImportProperties(pgo);

                Assertion.AssertEquals(6, pg.Count);
                Assertion.AssertEquals("fooout", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barout", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazout", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazout", pg["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pg["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pg["gaz"].FinalValueEscaped);

                pg.SetProperty(new BuildProperty("foo", "fooout2", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("gaz", "gazout2", PropertyType.OutputProperty));

                Assertion.AssertEquals("fooout2", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("gazout2", pg["gaz"].FinalValueEscaped);

                pg.RemoveProperty("baz");
                pg.RevertAllOutputProperties();

                Assertion.AssertEquals(3, pg.Count);
                Assertion.AssertEquals("fooval", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertNull(pg["baz"]);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertNull(pg["barb"]);
            }

            ///
            ///
            /// <owner>SumedhK</owner>
            [Test]
            public void ClonePropertyGroup()
            {
                BuildPropertyGroup pg = new BuildPropertyGroup();
                pg.SetProperty("foo", "fooval");
                pg.SetProperty(new BuildProperty("bar", "barval", PropertyType.EnvironmentProperty));
                pg.SetProperty(new BuildProperty("baz", "bazval", PropertyType.GlobalProperty));
                pg.SetProperty(new BuildProperty("caz", "cazval", PropertyType.ImportedProperty));
                pg.SetProperty(new BuildProperty("barb", "barbval", PropertyType.OutputProperty));

                pg.SetProperty(new BuildProperty("foo", "fooout", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("barb", "barbout", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("gaz", "gazout", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("foo", "fooout2", PropertyType.OutputProperty));

                BuildPropertyGroup pgsc = pg.Clone(false /* shallow clone */);
                BuildPropertyGroup pgdc = pg.Clone(true /* deep clone */);

                Assertion.AssertEquals(6, pg.Count);
                Assertion.AssertEquals("fooout2", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pg["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pg["gaz"].FinalValueEscaped);

                Assertion.AssertEquals(6, pgsc.Count);
                Assertion.AssertEquals("fooout2", pgsc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgsc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgsc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgsc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgsc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgsc["gaz"].FinalValueEscaped);

                Assertion.AssertEquals(6, pgdc.Count);
                Assertion.AssertEquals("fooout2", pgdc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgdc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgdc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgdc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgdc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgdc["gaz"].FinalValueEscaped);

                pg.RevertAllOutputProperties();

                Assertion.AssertEquals(4, pg.Count);
                Assertion.AssertEquals("fooval", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertNull(pg["barb"]);
                Assertion.AssertNull(pg["gaz"]);

                Assertion.AssertEquals(6, pgsc.Count);
                Assertion.AssertEquals("fooout2", pgsc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgsc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgsc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgsc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgsc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgsc["gaz"].FinalValueEscaped);

                Assertion.AssertEquals(6, pgdc.Count);
                Assertion.AssertEquals("fooout2", pgdc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgdc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgdc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgdc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgdc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgdc["gaz"].FinalValueEscaped);

                pgsc.RevertAllOutputProperties();

                Assertion.AssertEquals(4, pg.Count);
                Assertion.AssertEquals("fooval", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertNull(pg["barb"]);
                Assertion.AssertNull(pg["gaz"]);

                Assertion.AssertEquals(4, pgsc.Count);
                Assertion.AssertEquals("fooval", pgsc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgsc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgsc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgsc["caz"].FinalValueEscaped);
                Assertion.AssertNull(pgsc["barb"]);
                Assertion.AssertNull(pgsc["gaz"]);

                Assertion.AssertEquals(6, pgdc.Count);
                Assertion.AssertEquals("fooout2", pgdc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgdc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgdc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgdc["caz"].FinalValueEscaped);
                Assertion.AssertEquals("barbout", pgdc["barb"].FinalValueEscaped);
                Assertion.AssertEquals("gazout", pgdc["gaz"].FinalValueEscaped);

                pgdc.RevertAllOutputProperties();

                Assertion.AssertEquals(4, pg.Count);
                Assertion.AssertEquals("fooval", pg["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pg["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pg["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pg["caz"].FinalValueEscaped);
                Assertion.AssertNull(pg["barb"]);
                Assertion.AssertNull(pg["gaz"]);

                Assertion.AssertEquals(4, pgsc.Count);
                Assertion.AssertEquals("fooval", pgsc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgsc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgsc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgsc["caz"].FinalValueEscaped);
                Assertion.AssertNull(pgsc["barb"]);
                Assertion.AssertNull(pgsc["gaz"]);

                Assertion.AssertEquals(4, pgdc.Count);
                Assertion.AssertEquals("fooval", pgdc["foo"].FinalValueEscaped);
                Assertion.AssertEquals("barval", pgdc["bar"].FinalValueEscaped);
                Assertion.AssertEquals("bazval", pgdc["baz"].FinalValueEscaped);
                Assertion.AssertEquals("cazval", pgdc["caz"].FinalValueEscaped);
                Assertion.AssertNull(pgdc["barb"]);
                Assertion.AssertNull(pgdc["gaz"]);
            }

            ///
            /// Tests the IsEquivalent method on BuildPropertyGroup, when the two PGs have a
            /// different number of properties.
            ///
            /// <owner>RGoel</owner>
            [Test]
            public void PropertyGroupIsEquivalent_DifferentCount()
            {
                BuildPropertyGroup pg1 = new BuildPropertyGroup();
                BuildPropertyGroup pg2 = new BuildPropertyGroup();

                pg1.SetProperty("Elmo", "Red");
                pg1.SetProperty("BigBird", "Yellow");
                pg1.SetProperty("OscartheGrouch", "Green");

                pg2.SetProperty("Elmo", "Red");
                pg2.SetProperty("BigBird", "Yellow");

                // The two property bags are not equivalent.
                Assertion.Assert(!pg1.IsEquivalent(pg2));
            }

            ///
            /// Tests the IsEquivalent method on BuildPropertyGroup, when the two PGs have differing
            /// cases on the property names.
            ///
            /// <owner>RGoel</owner>
            [Test]
            public void PropertyGroupIsEquivalent_DifferentCaseOnName()
            {
                BuildPropertyGroup pg1 = new BuildPropertyGroup();
                BuildPropertyGroup pg2 = new BuildPropertyGroup();

                pg1.SetProperty("oscarthegrouch", "Green");
                pg1.SetProperty("bigbird", "Yellow");
                pg1.SetProperty("elmo", "Red");

                pg2.SetProperty("Elmo", "Red");
                pg2.SetProperty("BigBird", "Yellow");
                pg2.SetProperty("OscartheGrouch", "Green");

                // The two property bags are not equivalent.
                Assertion.Assert(pg1.IsEquivalent(pg2));
            }

            ///
            /// Tests the IsEquivalent method on BuildPropertyGroup, when the two PGs have differing
            /// cases on the property values.
            ///
            /// <owner>RGoel</owner>
            [Test]
            public void PropertyGroupIsEquivalent_DifferentCaseOnValue()
            {
                BuildPropertyGroup pg1 = new BuildPropertyGroup();
                BuildPropertyGroup pg2 = new BuildPropertyGroup();

                pg1.SetProperty("Elmo", "Red");
                pg1.SetProperty("BigBird", "Yellow");
                pg1.SetProperty("OscartheGrouch", "green");

                pg2.SetProperty("Elmo", "Red");
                pg2.SetProperty("BigBird", "Yellow");
                pg2.SetProperty("OscartheGrouch", "Green");

                // The two property bags are not equivalent.
                Assertion.Assert(!pg1.IsEquivalent(pg2));
            }

            ///
            /// Tests the IsEquivalent method on BuildPropertyGroup, when one of the PGs has a blank
            /// property value.
            ///
            /// <owner>RGoel</owner>
            [Test]
            public void PropertyGroupIsEquivalent_BlankPropertyValue()
            {
                BuildPropertyGroup pg1 = new BuildPropertyGroup();
                BuildPropertyGroup pg2 = new BuildPropertyGroup();

                pg1.SetProperty("Elmo", "Red");
                pg1.SetProperty("BigBird", "Yellow");
                pg1.SetProperty("OscartheGrouch", "Green");

                pg2.SetProperty("Elmo", "Red");
                pg2.SetProperty("BigBird", "");
                pg2.SetProperty("OscartheGrouch", "Green");

                // The two property bags are not equivalent.
                Assertion.Assert(!pg1.IsEquivalent(pg2));
            }

            ///
            /// Test that the ImportInitialProperties method imports the properties from the given
            /// BuildPropertyGroup instances in the correct order.
            ///
            [Test]
            public void ImportInitialPropertiesHasCorrectPrecedence()
            {
                BuildPropertyGroup environmentProperties = new BuildPropertyGroup();
                environmentProperties.SetProperty("Property1", "Value1");
                environmentProperties.SetProperty("Property2", "Value2");
                environmentProperties.SetProperty("Property3", "Value3");
                environmentProperties.SetProperty("Property4", "Value4");
                BuildPropertyGroup reservedProperties = new BuildPropertyGroup();
                reservedProperties.SetProperty("Property2", "Value5");
                reservedProperties.SetProperty("Property3", "Value6");
                reservedProperties.SetProperty("Property4", "Value7");
                BuildPropertyGroup toolsVersionDependentProperties = new BuildPropertyGroup();
                toolsVersionDependentProperties.SetProperty("Property3", "Value8");
                toolsVersionDependentProperties.SetProperty("Property4", "Value9");
                BuildPropertyGroup globalProperties = new BuildPropertyGroup();
                globalProperties.SetProperty("Property4", "Value10");

                BuildPropertyGroup evaluatedProperties = new BuildPropertyGroup();
                evaluatedProperties.ImportInitialProperties(environmentProperties, reservedProperties, toolsVersionDependentProperties, globalProperties);

                Assertion.AssertEquals("Value10", evaluatedProperties["Property4"].Value);
                Assertion.AssertEquals("Value8",  evaluatedProperties["Property3"].Value);
                Assertion.AssertEquals("Value5",  evaluatedProperties["Property2"].Value);
                Assertion.AssertEquals("Value1",  evaluatedProperties["Property1"].Value);
            }

            [Test]
            [ExpectedException(typeof(InvalidProjectFileException))]
            public void ItemGroupInAPropertyGroupCondition()
            {
                Project p = ObjectModelHelpers.CreateInMemoryProject(@"

                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>

                        <ItemGroup>
                            <x Include=`x1`/>
                        </ItemGroup>

                        <PropertyGroup Condition=`@(x)=='x1'`>
                            @(x)
                        </PropertyGroup>

                        <Target Name=`t`>
                            <Message Text=`[$(a)]`/>
                        </Target>

                    </Project>

                ");

                p.Build(new string[] { "t" }, null);
            }

            [Test]
            public void RemoveProperty()
            {
                Project p = ObjectModelHelpers.CreateInMemoryProject(@"

                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>

                        <PropertyGroup>
                            123
                            456
                        </PropertyGroup>

                        <PropertyGroup>
                            <c>789</c>
                        </PropertyGroup>

                    </Project>

                ");

                BuildPropertyGroup[] propertyGroups = new BuildPropertyGroup[2];
                p.PropertyGroups.CopyTo(propertyGroups, 0);

                BuildPropertyGroup first = propertyGroups[0].Count == 2 ? propertyGroups[0] : propertyGroups[1];
                BuildPropertyGroup second = propertyGroups[1].Count == 1 ? propertyGroups[1] : propertyGroups[0];

                BuildProperty property = null;
                foreach (BuildProperty tempProperty in first)
                {
                    if (tempProperty.Name.Equals("a", StringComparison.OrdinalIgnoreCase))
                    {
                        property = tempProperty;
                        break;
                    }
                }

                first.RemoveProperty(property);

                Assertion.AssertEquals("First property group should now only have 1 property.", 1, first.Count);
                Assertion.AssertEquals("Second property group should still have 1 property.", 1, second.Count);

                Assertion.Assert("Project xml should not have a definition for property 'a'.", !p.Xml.Contains(@""));
            }

            [Test]
            [ExpectedException(typeof(InvalidOperationException))]
            public void RemovePropertyFromPropertyGroupThatIsntItsParent()
            {
                Project p = ObjectModelHelpers.CreateInMemoryProject(@"

                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>

                        <PropertyGroup>
                            123
                            456
                        </PropertyGroup>

                        <PropertyGroup>
                            <c>789</c>
                        </PropertyGroup>

                    </Project>

                ");

                BuildPropertyGroup[] propertyGroups = new BuildPropertyGroup[2];
                p.PropertyGroups.CopyTo(propertyGroups, 0);

                BuildPropertyGroup first = propertyGroups[0].Count == 2 ? propertyGroups[0] : propertyGroups[1];
                BuildPropertyGroup second = propertyGroups[1].Count == 1 ? propertyGroups[1] : propertyGroups[0];

                BuildProperty property = null;
                foreach (BuildProperty tempProperty in first)
                {
                    if (tempProperty.Name.Equals("a", StringComparison.OrdinalIgnoreCase))
                    {
                        property = tempProperty;
                        break;
                    }
                }

                //this should throw because the property comes from another property group
                second.RemoveProperty(property);
            }

            [Test]
            public void SetGlobalPropertyAfterLoadBeforeBuild()
            {
                MockLogger logger = new MockLogger();

                Project project = ObjectModelHelpers.CreateInMemoryProject(@"
                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                        <Target Name=`log_property`>
                            <Message Text=`[$(p)]`/>
                        </Target>
                    </Project>
                ", logger);

                BuildPropertyGroup globals = project.GlobalProperties;

                // Set a property before building -- this should work
                BuildProperty p = new BuildProperty("p", "v1");
                globals.SetProperty(p);

                project.Build();

                logger.AssertLogContains("[v1]");
            }

            [Test]
            [ExpectedException(typeof(InvalidOperationException))]
            public void SetGlobalPropertyToDifferentValueDuringBuild()
            {
                SetPropertyDuringBuild("v1", "v2");
            }

            [Test]
            public void SetGlobalPropertyDuringBuildToValueItAlreadyHas()
            {
                MockLogger logger = SetPropertyDuringBuild("v1", "v1");
                logger.AssertLogContains("[v1]");
            }

            private MockLogger SetPropertyDuringBuild(string initialValue, string newValue)
            {
                Thread t = null;
                MockLogger logger = new MockLogger();

                try
                {
                    Project project = ObjectModelHelpers.CreateInMemoryProject(String.Format(@"
                    <Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>
                        <UsingTask TaskName=`WaitForSignal` AssemblyFile=`{0}`/>

                        <Target Name=`wait`>
                            <WaitForSignal/>
                            <Message Text=`[$(p)]`/>
                        </Target>
                    </Project>

                ", new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath), logger);

                    BuildPropertyGroup globals = project.GlobalProperties;
                    Console.WriteLine("Setting property to " + initialValue);
                    globals.SetProperty("p", initialValue);

                    // Set a property during build -- this should fail
                    t = new Thread(BuildSuppliedProject);
                    t.Start(project);

                    // Wait for the build to get going
                    while (!WaitForSignal.ReadyForSignal)
                    {
                        Thread.Sleep(50);
                    }

                    // Now set a property
                    Console.WriteLine("Setting property to " + newValue);
                    globals.SetProperty("p", newValue);
                }
                finally
                {
                    if (t != null)
                    {
                        // Clean up the thread, if necessary
                        while (!WaitForSignal.ReadyForSignal)
                        {
                            Thread.Sleep(50);
                        }
                        WaitForSignal.Signal();
                        t.Join();
                    }
                }

                return logger;
            }

            private void BuildSuppliedProject(Object o)
            {
                Project project = (Project) o;
                project.Build();
            }

            [Test]
            public void PropertyGroupCustomSerialization()
            {
                BuildPropertyGroup pg = new BuildPropertyGroup();
                pg.SetProperty(new BuildProperty("bar", "barval", PropertyType.EnvironmentProperty));
                pg.SetProperty(new BuildProperty("baz", "bazval", PropertyType.GlobalProperty));
                pg.SetProperty(new BuildProperty("caz", "cazval", PropertyType.ImportedProperty));
                pg.SetProperty(new BuildProperty("barb", "barbout", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("gaz", "gazout", PropertyType.OutputProperty));
                pg.SetProperty(new BuildProperty("foo", "fooout2", PropertyType.OutputProperty));

                MemoryStream stream = new MemoryStream();
                BinaryWriter writer = new BinaryWriter(stream);
                BinaryReader reader = new BinaryReader(stream);
                try
                {
                    stream.Position = 0;
                    pg.WriteToStream(writer);
                    long streamWriteEndPosition = stream.Position;

                    stream.Position = 0;
                    BuildPropertyGroup pg2 = new BuildPropertyGroup();
                    pg2.CreateFromStream(reader);
                    long streamReadEndPosition = stream.Position;
                    Assert.IsTrue(streamWriteEndPosition == streamReadEndPosition, "Stream end positions should be equal");
                    Assert.AreEqual(6, pg.Count);
                    Assert.AreEqual("fooout2", pg2["foo"].FinalValueEscaped);
                    Assert.AreEqual("barval", pg2["bar"].FinalValueEscaped);
                    Assert.AreEqual("bazval", pg2["baz"].FinalValueEscaped);
                    Assert.AreEqual("cazval", pg2["caz"].FinalValueEscaped);
                    Assert.AreEqual("barbout", pg2["barb"].FinalValueEscaped);
                    Assert.AreEqual("gazout", pg2["gaz"].FinalValueEscaped);
                }
                finally
                {
                    reader.Close();
                    writer = null;
                    stream = null;
                }
            }
        }

        ///
        /// Task sets "Ready" when it's started, and sleeps until "Signal" is set.
        /// Useful if you want a test to do something while a build is in progress.
        ///
        public class WaitForSignal : Microsoft.Build.Utilities.Task
        {
            private static bool signal;
            private static bool readyForSignal;
            private static Object locker = new Object();

            public static void Signal()
            {
                lock (locker)
                {
                    // Lock, so that we don't race the caller's check for ready
                    if (readyForSignal)
                    {
                        signal = true;
                        readyForSignal = false;
                    }
                }
            }

            public static bool ReadyForSignal
            {
                get { return readyForSignal; }
            }

            public override bool Execute()
            {
                signal = false;
                readyForSignal = true;

                Console.WriteLine("waiting for signal");
                while (!signal)
                {
                    Thread.Sleep(50);
                }
                Console.WriteLine(" ... signaled");

                readyForSignal = false;
                signal = false;

                return true;
            }
        }
    }

{'repo_name': 'microsoft/msbuild', 'stars': '4287', 'repo_language': 'C#', 'file_name': 'OptProf.json', 'mime_type': 'text/plain', 'hash': -6334116874136634895, 'source_dataset': 'data'}


//===--- ImmutableTextBuffer.h - --------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_SOURCEKIT_SUPPORT_IMMUTABLETEXTBUFFER_H
#define LLVM_SOURCEKIT_SUPPORT_IMMUTABLETEXTBUFFER_H

#include "SourceKit/Core/LLVM.h"
#include "SourceKit/Support/ThreadSafeRefCntPtr.h"
#include "swift/Basic/ThreadSafeRefCounted.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/Mutex.h"
#include <functional>
#include <memory>

namespace llvm {
  class MemoryBuffer;
  class SourceMgr;
}

namespace SourceKit {

class ImmutableTextUpdate;
typedef RefPtr<ImmutableTextUpdate> ImmutableTextUpdateRef;

class ImmutableTextBuffer;
typedef RefPtr<ImmutableTextBuffer> ImmutableTextBufferRef;

class ReplaceImmutableTextUpdate;
typedef RefPtr<ReplaceImmutableTextUpdate> ReplaceImmutableTextUpdateRef;

class ImmutableTextSnapshot;
typedef RefPtr<ImmutableTextSnapshot> ImmutableTextSnapshotRef;

class EditableTextBuffer;
typedef RefPtr<EditableTextBuffer> EditableTextBufferRef;

class ImmutableTextUpdate : public ThreadSafeRefCountedBaseVPTR {
public:
  enum class Kind {
    Buffer,
    Replace,
  };

  virtual ~ImmutableTextUpdate() = default;

  ImmutableTextUpdateRef getNext() const { return Next; }
  Kind getKind() const { return K; }
  uint64_t getStamp() const { return Stamp; }

protected:
  ImmutableTextUpdate(Kind K, uint64_t Stamp) : K(K), Stamp(Stamp) {}

private:
  Kind K;
  uint64_t Stamp;
  ThreadSafeRefCntPtr<ImmutableTextUpdate> Next;

  friend class EditableTextBuffer;
  virtual void anchor();
};

class ImmutableTextBuffer : public ImmutableTextUpdate {
  std::unique_ptr<llvm::SourceMgr> SrcMgr;
  unsigned BufId;

public:
  explicit ImmutableTextBuffer(std::unique_ptr<llvm::MemoryBuffer> MemBuf,
                               uint64_t Stamp);
  ImmutableTextBuffer(StringRef Filename, StringRef Text, uint64_t Stamp);

  StringRef getText() const;
  StringRef getFilename() const;

  /// Returns the internal memory buffer.
  /// The caller must make sure that the pointer does not outlive the
  /// ImmutableTextBuffer object that it came from.
  const llvm::MemoryBuffer *getInternalBuffer() const;

  std::pair<unsigned, unsigned> getLineAndColumn(unsigned ByteOffset) const;

  static bool classof(const ImmutableTextUpdate *ITD) {
    return ITD->getKind() == Kind::Buffer;
  }
};

class ReplaceImmutableTextUpdate : public ImmutableTextUpdate {
  std::unique_ptr<llvm::MemoryBuffer> Buf;
  unsigned ByteOffset;
  unsigned Length;

public:
  ReplaceImmutableTextUpdate(unsigned ByteOffset, unsigned Length,
                             StringRef Text, uint64_t Stamp);

  unsigned getByteOffset() const { return ByteOffset; }
  unsigned getLength() const { return Length; }
  StringRef getText() const;

  static bool classof(const ImmutableTextUpdate *ITD) {
    return ITD->getKind() == Kind::Replace;
  }
};

class ImmutableTextSnapshot :
    public ThreadSafeRefCountedBase<ImmutableTextSnapshot> {

  EditableTextBufferRef EditableBuf;
  ImmutableTextBufferRef BufferStart;
  ImmutableTextUpdateRef DiffEnd;

  ImmutableTextSnapshot(EditableTextBufferRef EditableBuf,
                        ImmutableTextBufferRef Buffer)
    : EditableBuf(std::move(EditableBuf)),
      BufferStart(std::move(Buffer)), DiffEnd(BufferStart) {}

  ImmutableTextSnapshot(EditableTextBufferRef EditableBuf,
                        ImmutableTextBufferRef BufferStart,
                        ImmutableTextUpdateRef DiffEnd)
    : EditableBuf(std::move(EditableBuf)),
      BufferStart(std::move(BufferStart)), DiffEnd(std::move(DiffEnd)) {}

friend class EditableTextBuffer;

public:
  StringRef getFilename() const;

  uint64_t getStamp() const;

  ImmutableTextBufferRef getBuffer() const;

  bool isFromSameBuffer(ImmutableTextSnapshotRef Other) const {
    return Other->EditableBuf.get() == EditableBuf.get();
  }

  EditableTextBufferRef getEditableBuffer() const {
    return EditableBuf;
  }

  bool precedesOrSame(ImmutableTextSnapshotRef Other);

  bool foreachReplaceUntil(ImmutableTextSnapshotRef EndSnapshot,
                     std::function<bool(ReplaceImmutableTextUpdateRef Upd)> Fn);
};

class EditableTextBuffer : public ThreadSafeRefCountedBase<EditableTextBuffer> {
  llvm::sys::Mutex EditMtx;
  ImmutableTextBufferRef Root;
  ImmutableTextUpdateRef CurrUpd;
  std::string Filename;

public:
  explicit EditableTextBuffer(StringRef Filename, StringRef Text = StringRef());

  StringRef getFilename() const { return Filename; }

  ImmutableTextSnapshotRef getSnapshot() const;

  ImmutableTextBufferRef getBuffer() const {
    return getSnapshot()->getBuffer();
  }

  ImmutableTextSnapshotRef insert(unsigned ByteOffset, StringRef Text);
  ImmutableTextSnapshotRef erase(unsigned ByteOffset, unsigned Length);
  ImmutableTextSnapshotRef replace(unsigned ByteOffset, unsigned Length,
                                   StringRef Text);

private:
  ImmutableTextSnapshotRef addAtomicUpdate(ImmutableTextUpdateRef NewUpd);
  ImmutableTextBufferRef getBufferForSnapshot(
      const ImmutableTextSnapshot &Snap);
  void refresh();
  friend class ImmutableTextSnapshot;
};

class EditableTextBufferManager {
  llvm::sys::Mutex Mtx;
  llvm::StringMap<EditableTextBufferRef> FileBufferMap;

public:
  EditableTextBufferRef getOrCreateBuffer(StringRef Filename,
                                          StringRef Text = StringRef());
  EditableTextBufferRef resetBuffer(StringRef Filename,
                                    StringRef Text = StringRef());
};

} // namespace SourceKit

#endif

{'repo_name': 'Polidea/SiriusObfuscator', 'stars': '376', 'repo_language': 'C++', 'file_name': 'xray-extract.cc', 'mime_type': 'text/x-c++', 'hash': 5275621184340622281, 'source_dataset': 'data'}


#region Copyright (C) 2007-2018 Team MediaPortal

/*
    Copyright (C) 2007-2018 Team MediaPortal
    http://www.team-mediaportal.com

    This file is part of MediaPortal 2

    MediaPortal 2 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.

    MediaPortal 2 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 MediaPortal 2. If not, see <http://www.gnu.org/licenses/>.
*/

#endregion

using System.Collections.Generic;
using MediaPortal.Plugins.SlimTv.Interfaces.Items;
using System;
using System.Threading.Tasks;
using MediaPortal.Common.Async;
using MediaPortal.Common.Services.ServerCommunication;

namespace MediaPortal.Plugins.SlimTv.Interfaces
{

  public interface IProgramInfoAsync
  {
    /// <summary>
    /// Tries to get the current and next program for the given <paramref name="channel"/>.
    /// </summary>
    /// <param name="channel">Channel</param>
    /// <returns>
    /// <see cref="AsyncResult{T}.Success"/> <c>true</c> if programs could be found.
    /// <see cref="AsyncResult{T}.Result"/> an array of now/next programs.
    /// </returns>
    Task<AsyncResult<IProgram[]>> GetNowNextProgramAsync(IChannel channel);

    /// <summary>
    /// Tries to get the current and next program for all channels of the the given <paramref name="channelGroup"/>.
    /// </summary>
    /// <param name="channelGroup">Channel group</param>
    /// <returns>
    /// <see cref="AsyncResult{T}.Success"/> <c>true</c> if programs could be found.
    /// <see cref="AsyncResult{T}.Result"/> programs.
    /// </returns>
    Task<AsyncResult<IDictionary<int, IProgram[]>>> GetNowAndNextForChannelGroupAsync(IChannelGroup channelGroup);

    /// <summary>
    /// Tries to get a list of programs for the given <paramref name="channel"/> and time range.
    /// </summary>
    /// <param name="channel">Channel</param>
    /// <param name="from">Time from</param>
    /// <param name="to">Time to</param>
    /// <returns>
    /// <see cref="AsyncResult{T}.Success"/> <c>true</c> if at least one program could be found.
    /// <see cref="AsyncResult{T}.Result"/> programs.
    /// </returns>
    Task<AsyncResult<IList<IProgram>>> GetProgramsAsync(IChannel channel, DateTime from, DateTime to);

    /// <summary>
    /// Tries to get a list of programs for the given <paramref name="title"/> and time range.
    /// </summary>
    /// <param name="title">Title</param>
    /// <param name="from">Time from</param>
    /// <param name="to">Time to</param>
    /// <returns>
    /// <see cref="AsyncResult{T}.Success"/> <c>true</c> if at least one program could be found.
    /// <see cref="AsyncResult{T}.Result"/> programs.
    /// </returns>
    Task<AsyncResult<IList<IProgram>>> GetProgramsAsync(string title, DateTime from, DateTime to);

    /// <summary>
    /// Tries to get a list of programs for the given <paramref name="channelGroup"/> and time range.
    /// </summary>
    /// <param name="channelGroup">Channel group</param>
    /// <param name="from">Time from</param>
    /// <param name="to">Time to</param>
    /// <returns>
    /// <see cref="AsyncResult{T}.Success"/> <c>true</c> if at least one program could be found.
    /// <see cref="AsyncResult{T}.Result"/> programs.
    /// </returns>
    Task<AsyncResult<IList<IProgram>>> GetProgramsGroupAsync(IChannelGroup channelGroup, DateTime from, DateTime to);

    /// <summary>
    /// Gets a channel from an IProgram.
    /// </summary>
    /// <param name="program">Program.</param>
    /// <returns>
    /// <see cref="AsyncResult{T}.Success"/> <c>true</c> if at least one program could be found.
    /// <see cref="AsyncResult{T}.Result"/> Channel.
    /// </returns>
    Task<AsyncResult<IChannel>> GetChannelAsync(IProgram program);

    /// <summary>
    /// Gets a program by its <see cref="IProgram.ProgramId"/>.
    /// </summary>
    /// <param name="programId">Program ID.</param>
    /// <param name="program">Program.</param>
    /// <returns>True if succeeded.</returns>
    bool GetProgram(int programId, out IProgram program);
  }

    ///// <summary>
    ///// IProgramInfo defines all actions and properties for TV programs handling.
    ///// </summary>
    //public interface IProgramInfo
    //{
    //  /// <summary>
    //  /// Tries to get the current and next program for the given <paramref name="channel"/>.
    //  /// </summary>
    //  /// <param name="channel">Channel</param>
    //  /// <param name="programNow">Returns current program</param>
    //  /// <param name="programNext">Returns next program</param>
    //  /// <returns><c>true</c> if a program could be found</returns>
    //  bool GetNowNextProgram(IChannel channel, out IProgram programNow, out IProgram programNext);

    //  /// <summary>
    //  /// Tries to get the current and next program for all channels of the the given <paramref name="channelGroup"/>.
    //  /// </summary>
    //  /// <param name="channelGroup">Channel group</param>
    //  /// <param name="nowNextPrograms">Returns programs</param>
    //  /// <returns><c>true</c> if successful</returns>
    //  bool GetNowAndNextForChannelGroup(IChannelGroup channelGroup, out IDictionary<int, IProgram[]> nowNextPrograms);

    //  /// <summary>
    //  /// Tries to get a list of programs for the given <paramref name="channel"/> and time range.
    //  /// </summary>
    //  /// <param name="channel">Channel</param>
    //  /// <param name="from">Time from</param>
    //  /// <param name="to">Time to</param>
    //  /// <param name="programs">Returns programs</param>
    //  /// <returns><c>true</c> if at least one program could be found</returns>
    //  bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList<IProgram> programs);

    //  /// <summary>
    //  /// Tries to get a list of programs for the given <paramref name="title"/> and time range.
    //  /// </summary>
    //  /// <param name="title">Program title</param>
    //  /// <param name="from">Time from</param>
    //  /// <param name="to">Time to</param>
    //  /// <param name="programs">Returns programs</param>
    //  /// <returns><c>true</c> if at least one program could be found</returns>
    //  bool GetPrograms(string title, DateTime from, DateTime to, out IList<IProgram> programs);

    //  /// <summary>
    //  /// Tries to get a list of programs for all channels of the given <paramref name="channelGroup"/> and time range.
    //  /// </summary>
    //  /// <param name="channelGroup">Channel group</param>
    //  /// <param name="from">Time from</param>
    //  /// <param name="to">Time to</param>
    //  /// <param name="programs">Returns programs</param>
    //  /// <returns><c>true</c> if at least one program could be found</returns>
    //  bool GetProgramsGroup(IChannelGroup channelGroup, DateTime from, DateTime to, out IList<IProgram> programs);

    //  /// <summary>
    //  /// Tries to get a list of programs for the given <paramref name="channel"/>.
    //  /// </summary>
    //  /// <param name="channel">Channel</param>
    //  /// <param name="programs">Returns programs</param>
    //  /// <returns><c>true</c> if at least one program could be found</returns>
    //  bool GetScheduledPrograms(IChannel channel, out IList<IProgram> programs);

    //  /// <summary>
    //  /// Gets a channel from an IProgram.
    //  /// </summary>
    //  /// <param name="program">Program.</param>
    //  /// <param name="channel">Channel.</param>
    //  /// <returns>True if succeeded.</returns>
    //  bool GetChannel(IProgram program, out IChannel channel);

    //  /// <summary>
    //  /// Gets a program by its <see cref="IProgram.ProgramId"/>.
    //  /// </summary>
    //  /// <param name="programId">Program ID.</param>
    //  /// <param name="program">Program.</param>
    //  /// <returns>True if succeeded.</returns>
    //  bool GetProgram(int programId, out IProgram program);
    //}
  }

{'repo_name': 'MediaPortal/MediaPortal-2', 'stars': '275', 'repo_language': 'C#', 'file_name': 'AssemblyInfo.cs', 'mime_type': 'text/plain', 'hash': -7831508346867298003, 'source_dataset': 'data'}


#pragma once

#include "il2cpp-config.h"

#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif

#include <stdint.h>

#include "mscorlib_System_ValueType3507792607.h"

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif

// <PrivateImplementationDetails>/$ArrayType$56
struct  U24ArrayTypeU2456_t1703410330
{
public:
	union
	{
		struct
		{
			union
			{
			};
		};
		uint8_t U24ArrayTypeU2456_t1703410330__padding[56];
	};

public:
};

#ifdef __clang__
#pragma clang diagnostic pop
#endif

{'repo_name': 'andrewnakas/OpenBrushVR', 'stars': '169', 'repo_language': 'C++', 'file_name': 'AudioManager.asset', 'mime_type': 'text/plain', 'hash': -5032455411690098092, 'source_dataset': 'data'}


<!DOCTYPE html>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>NUnit.org</title>
  <meta name="description" content="NUnit is the most popular unit test framework for .NET.">

  <link rel="stylesheet" href="/css/main.css"">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
  <link rel="alternate" type="application/rss+xml" title="NUnit.org" href="/rss.xml"">
  <link rel="alternate" type="application/atom+xml" title="NUnit.org" href="/atom.xml" />
  <link rel="shortcut icon" href="/favicon.ico" />

        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        Toggle navigation

        </button>

 News

 Download

 Documentation

 Contact

 Twitter

 Gitter

 GitHub

Legacy Documentation. View NUnit 3 Documentation

Settings Dialog

The Settings Dialog is displayed using the Tools | Settings menu item and allows the user to
control some aspects of NUnit's operation. Beginning with NUnit 2.4.4, a tree-based dialog
replaced the older tabbed format.

Gui Settings - General

Gui Display

Full Gui

Displays the complete gui - as in prior versions of NUnit. This includes the
   test result tabs and the progress bar.

Mini Gui

Switches the display to the mini-gui, which consists of the tree display
   only.

Recent Files

The Display ... files in list TextBox allows the user to choose the number
of entries to display in the recent files list.

Normally, NUnit checks that project files still exist before
displaying them in the recent files list. This can cause long delays if the
file is on a network connection that is no longer available. Unchecking
Check that files exist before listing will avoid this delay, so
long as the missing file is not actually selected.

If Load most recent project at startup is checked, the GUI will load the
last file opened unless it is run with a specific filename or with the
/noload parameter.

Gui Settings - Tree Display

Tree View

The list box allows selecting the degree of expansion of the tree when tests are loaded:

Auto - selects a setting based on the space available for the tree display.

Expand - expands all tests

Collapse - collapses all tests

Hide Tests - expands all suites except for the fixtures themselves.

If Clear results when reloading is checked, an automatic or manual reload will reinitialize all
test nodes in the tree (grey display) - if it is not checked, result information for tests that do
not seem to have changed will be retained.

If Save visual state of each project is checked, NUnit saves the state of the tree
and restores it when the project is next opened. The information saved includes which
branches of the tree are expanded, the selected node, any checked nodes and any
category selection.

If Show Checkboxes is checked, the tree includes checkboxes, which may
   be used to select multiple tests for running. This setting is also available
   in the View | Tree menu.

Test Structure

If Automatic Namespace suites is selected, tests will be
   shown in a hierarchical listing based on namespaces. This is the
   standard display as used in versions prior to NUnit 2.4.

If Flat list of TestFixtures is selected, tests will be
   shown as a sequential list of fixtures.

Gui Settings - Test Results

Errors Tab

Check Display Errors and Failures Tab to display the
Errors and Failures tab, which shows information about failing tests.

Check Enable Failure ToolTips to display the tip window over the
Errors and Failures display and the stack trace. Clear it if you prefer not
to see the tip window.

Check Enable Word Wrap to turn on word wrapping
in the Errors and Failures display. While you can select this item and the
preceding one at the same time, they do not interact well, so you will
normally choose one or the other.

Not Run Tab

Check Display Tests Not Run Tab to display the
Tests Not Run tab, which shows information about tests that were
skipped or ignored.

Gui Settings - Text Output

Select Tab

The Select Tab dropdown list is used to select one of the output tabs, for which
settings are to be viewed or changed. It also contains entries that allow
you to add a new tab or edit the list of tabs.

The Restore Defaults button is used to restore the default
setting, which is a single tab labeled "Text Output." The default tab
displays all types of output and includes a label for each test that
displays text.

The Title text box is used to modify the title displayed
for the selected output tab.

Enabled is checked by default. If you uncheck it,
the selected tab will be removed from the tab control. This allows you to temporarily
suppress output to a tab without actually removing its definition.

Content

The four check boxes enable or disable a particular type of output
on the selected output window. For each type, the display captures
output produced while your test is running - either by the test
itself or by the program you are testing.

Standard Output

Captures all output written to Console.Out.

Error Output

Captures all output written to Console.Error.

Trace Output

Captures all output written to Trace or Debug.

Log Output

Captures output written to a log4net log. NUnit captures
all output at the Error level or above unless another level
is specified for the DefaultLogThreshold setting in the
configuration file for the test assembly or project.

Test Labels

Check Display TestCase Labels to precede text in the output window
with the name of the test that produced it.

Check Suppress label if no output is displayed to eliminate display
of labels for tests that produce no output in the window.

Test Loader Settings - Assembly Isolation

Default Process Model

These settings determine NUnit's default use of operating system
processes and may be overridden by settings in the NUnit project.

If Run tests directly in the NUnit process is selected,
all tests are run in a test domain in the same process as NUnit.
This is the way previous versions of NUnit ran tests and is the
default setting.

If Run tests in a single separate process is selected,
a separate process is used for all tests.

If Run tests in a separate process per Assembly  is selected,
a separate process is used for each test assembly.

Default Domain Usage

If Use a separate AppDomain per Assembly is selected, each assembly
   in a multiple-assembly test run will be loaded in a separate AppDomain.
   This setting is not available when Run tests in a separate process
   per Assembly is selected above.

If Use a single AppDomain for all tests is selected, all assemblies in
   a multiple-assembly test run will use the same AppDomain. This was
   the standard behavior of NUnit prior to version 2.4 and is the
   default setting.

If Merge tests across assemblies is checked, the display of tests
   will not be divided across assemblies. If automatic namespace suites are
   used, they will be merged across all assemblies. This option is only
   available when tests are run in the same appdomain.

Test Loader Settings - Assembly Reload

Assembly Reload

If Reload before each test run is checked, a reload will occur whenever the run button is
pressed whether the assemblies appear to have changed or not.

If Reload when test assembly changes is checked, assemblies are watched for any change and
an automatic reload is initiated. This item is disabled on Windows 98 or ME.

If Re-run last tests run is checked, tests are re-run whenever a Reload
   takes place.

Test Loader Settings - Advanced

Shadow Copy

NUnit normally uses .Net shadow-copying in order to allow you to edit
and recompile assemblies while it is running. Uncheck this box to disable
shadow-copy only if you have a particular problem that requires it.

Note: If you are tempted to disable shadow copy in order to access
files in the same directory as your assembly, you should be aware that there
are alternatives. Consider using the Assembly.Codebase property rather than
Assembly.Location.

IDE Support Settings - Visual Studio

Visual Studio

If Enable Visual Studio Support is checked, the user will be able to open Visual Studio projects
and solutions and add Visual Studio projects to existing test projects.

NUnit 2.5.7

Getting Started

Assertions

Constraints

Attributes

Running Tests

Console Runner

Gui Runner

Command-Line

Main Menu

Context Menu

Settings Dialog

Addins Dialog

Test Properties

Configuration Editor

Project Editor

PNUnit Runner

Runtime Selection

Assembly Isolation

Configuration Files

Multiple Assemblies

Visual Studio Support

Extensibility

Release Notes

Samples

License

        NUnit 2 Documentation Copyright © 2014, Charlie Poole. All rights reserved.

        Supported by the
        .NET Foundation

{'repo_name': 'nunit/docs', 'stars': '604', 'repo_language': 'PowerShell', 'file_name': 'settings.json', 'mime_type': 'text/plain', 'hash': 6723510106186852916, 'source_dataset': 'data'}


/*
Copyright Rene Rivera 2008-2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/

#ifndef BOOST_PREDEF_COMPILER_PALM_H
#define BOOST_PREDEF_COMPILER_PALM_H

#include <boost/predef/version_number.h>
#include <boost/predef/make.h>

/*`
[heading `BOOST_COMP_PALM`]

Palm C/C++ compiler.
Version number available as major, minor, and patch.

[table
    [[__predef_symbol__] [__predef_version__]]

    [[`_PACC_VER`] [__predef_detection__]]

    [[`_PACC_VER`] [V.R.P]]
    ]
 */

#define BOOST_COMP_PALM BOOST_VERSION_NUMBER_NOT_AVAILABLE

#if defined(_PACC_VER)
#   define BOOST_COMP_PALM_DETECTION BOOST_PREDEF_MAKE_0X_VRRPP000(_PACC_VER)
#endif

#ifdef BOOST_COMP_PALM_DETECTION
#   if defined(BOOST_PREDEF_DETAIL_COMP_DETECTED)
#       define BOOST_COMP_PALM_EMULATED BOOST_COMP_PALM_DETECTION
#   else
#       undef BOOST_COMP_PALM
#       define BOOST_COMP_PALM BOOST_COMP_PALM_DETECTION
#   endif
#   define BOOST_COMP_PALM_AVAILABLE
#   include <boost/predef/detail/comp_detected.h>
#endif

#define BOOST_COMP_PALM_NAME "Palm C/C++"

#endif

#include <boost/predef/detail/test.h>
BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_PALM,BOOST_COMP_PALM_NAME)

#ifdef BOOST_COMP_PALM_EMULATED
#include <boost/predef/detail/test.h>
BOOST_PREDEF_DECLARE_TEST(BOOST_COMP_PALM_EMULATED,BOOST_COMP_PALM_NAME)
#endif

{'repo_name': 'sccn/lsl_archived', 'stars': '250', 'repo_language': 'C++', 'file_name': 'ReceiveData.m', 'mime_type': 'text/plain', 'hash': 4953879717129630587, 'source_dataset': 'data'}


		<title>NVIDIA(R) PhysX(R) SDK 3.4 API Reference: Member List</title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<LINK HREF="NVIDIA.css" REL="stylesheet" TYPE="text/css">

				Main Page
				Class Hierarchy
				Compound List
				Compound Members

PxPlane Member List
This is the complete list of members for PxPlane, including all inherited members.

contains(const PxVec3 &p) const 	PxPlane	 [inline]

d	PxPlane

distance(const PxVec3 &p) const 	PxPlane	 [inline]

n	PxPlane

normalize()	PxPlane	 [inline]

operator==(const PxPlane &p) const 	PxPlane	 [inline]

pointInPlane() const 	PxPlane	 [inline]

project(const PxVec3 &p) const 	PxPlane	 [inline]

PxPlane()	PxPlane	 [inline]

PxPlane(float nx, float ny, float nz, float distance)	PxPlane	 [inline]

PxPlane(const PxVec3 &normal, float distance)	PxPlane	 [inline]

PxPlane(const PxVec3 &point, const PxVec3 &normal)	PxPlane	 [inline]

PxPlane(const PxVec3 &p0, const PxVec3 &p1, const PxVec3 &p2)	PxPlane	 [inline]

Copyright © 2008-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com

{'repo_name': 'NVIDIAGameWorks/PhysX-3.4', 'stars': '2145', 'repo_language': 'C++', 'file_name': 'div_base.hpp', 'mime_type': 'text/x-c', 'hash': 1728079578583376518, 'source_dataset': 'data'}


# $Id: Makefile.tests 8481 2009-07-13 20:18:41Z abdelazer $
#
# This makefile does a "smoketest" of stylesheets for various
# output formats in the DocBook XSL Stylesheets release package.
# It doesn't actually check the output -- it's just useful for
# confirming whether each XSLT transformation actually executes
# successfully without any errors.
#
# To use it, run "make check" or just "make"

XSLTPROC=xsltproc
XSLTPROC_FLAGS=

TESTFILE=tests/refentry.007.xml
TESTFILE_NS=tests/refentry.007.ns.xml

NORMAL_STYLES=fo/docbook.xsl html/docbook.xsl xhtml/docbook.xsl
NORMAL_PROFILE_STYLES=fo/profile-docbook.xsl html/profile-docbook.xsl xhtml/profile-docbook.xsl
CHUNK_STYLES=html/chunk.xsl html/onechunk.xsl xhtml/chunk.xsl xhtml/onechunk.xsl
HELP_STYLES=htmlhelp/htmlhelp.xsl javahelp/javahelp.xsl eclipse/eclipse.xsl
MULTIFILE_STYLES=$(CHUNK_STYLES) $(HELP_STYLES)
CHUNK_PROFILE_STYLES=html/profile-chunk.xsl html/profile-onechunk.xsl xhtml/profile-chunk.xsl xhtml/profile-onechunk.xsl
HELP_PROFILE_STYLES=htmlhelp/profile-htmlhelp.xsl eclipse/profile-eclipse.xsl javahelp/profile-javahelp.xsl
MULTIFILE_PROFILE_STYLES=$(CHUNK_PROFILE_STYLES) $(HELP_PROFILE_STYLES)

MAN_STYLE=manpages/docbook.xsl
MAN_PROFILE_STYLE=manpages/profile-docbook.xsl

TWO_PROFILE_STYLE=profiling/profile.xsl

ROUNDTRIP_STYLES=roundtrip/dbk2ooo.xsl roundtrip/dbk2pages.xsl roundtrip/dbk2wordml.xsl
SLIDES_STYLES=slides/html/default.xsl slides/xhtml/default.xsl slides/fo/plain.xsl
WEBSITE_STYLES=website/website.xsl
WEBSITE_CHUNK_STYLES=website/chunk-website.xsl

# chunked output gets written to TMP_OUTPUT_DIR
TMP_OUTPUT_DIR=/tmp/smoketest-output/
# if you don't want TMP_OUTPUT_DIR and its contents deleted, unset
# SMOKETEST_CLEAN_TARGET; e.g. "make check SMOKETEST_CLEAN_TARGET=''"
SMOKETEST_CLEAN_TARGET=smoketest-clean

check: smoketest-make-tmp-dir smoketest-normal smoketest-normal-profile smoketest-chunk smoketest-chunk-profile smoketest-man smoketest-man-profile smoketest-two-profile $(SMOKETEST_CLEAN_TARGET)

smoketest-make-tmp-dir:
	$(RM) -r $(TMP_OUTPUT_DIR)
	mkdir '$(TMP_OUTPUT_DIR)'

smoketest-normal:
	for stylesheet in $(NORMAL_STYLES); do \
	echo "$(XSLT) $(TESTFILE) $$stylesheet > /dev/null"; \
	$(XSLT) $(TESTFILE) $$stylesheet > /dev/null; \
	echo "$(XSLT) $(TESTFILE_NS) $$stylesheet > /dev/null"; \
	$(XSLT) $(TESTFILE_NS) $$stylesheet > /dev/null; \
	done

smoketest-normal-profile:
	for stylesheet in $(NORMAL_PROFILE_STYLES); do \
	echo "$(XSLT) $(TESTFILE) $$stylesheet > /dev/null"; \
	$(XSLT) $(TESTFILE) $$stylesheet > /dev/null; \
	echo "$(XSLT) $(TESTFILE_NS) $$stylesheet > /dev/null"; \
	$(XSLT) $(TESTFILE_NS) $$stylesheet > /dev/null; \
	done

smoketest-chunk:
	for stylesheet in $(MULTIFILE_STYLES) ; do \
	$(XSLT) $(TESTFILE) $$stylesheet manifest.in.base.dir=1 base.dir=$(TMP_OUTPUT_DIR) ; \
	$(XSLT) $(TESTFILE_NS) $$stylesheet manifest.in.base.dir=1 base.dir=$(TMP_OUTPUT_DIR) ; \
	done;

smoketest-chunk-profile:
	for stylesheet in $(MULTIFILE_PROFILE_STYLES) ; do \
	$(XSLT) $(TESTFILE) $$stylesheet manifest.in.base.dir=1 base.dir=$(TMP_OUTPUT_DIR) ; \
	$(XSLT) $(TESTFILE_NS) $$stylesheet manifest.in.base.dir=1 base.dir=$(TMP_OUTPUT_DIR) ; \
	done;

smoketest-man:
	$(XSLT) $(TESTFILE) $(MAN_STYLE) man.output.in.separate.dir=1 man.output.base.dir=$(TMP_OUTPUT_DIR) ; \
	$(XSLT) $(TESTFILE_NS) $(MAN_STYLE) man.output.in.separate.dir=1 man.output.base.dir=$(TMP_OUTPUT_DIR) ;

smoketest-man-profile:
	$(XSLT) $(TESTFILE) $(MAN_PROFILE_STYLE) man.output.in.separate.dir=1 man.output.base.dir=$(TMP_OUTPUT_DIR) ; \
	$(XSLT) $(TESTFILE_NS) $(MAN_PROFILE_STYLE) man.output.in.separate.dir=1 man.output.base.dir=$(TMP_OUTPUT_DIR) ;

smoketest-two-profile:
	$(XSLT) $(TESTFILE_NS) $(TWO_PROFILE_STYLE) > /dev/null ;

smoketest-clean:
	$(RM) -r $(TMP_OUTPUT_DIR)

{'repo_name': 'ironbee/ironbee', 'stars': '278', 'repo_language': 'XSLT', 'file_name': 'Makefile.am', 'mime_type': 'text/plain', 'hash': -6410850392944075263, 'source_dataset': 'data'}


/*
 * Copyright (c) 2016 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 *
 * DRM core format related functions
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting documentation, and
 * that the name of the copyright holders not be used in advertising or
 * publicity pertaining to distribution of the software without specific,
 * written prior permission.  The copyright holders make no representations
 * about the suitability of this software for any purpose.  It is provided "as
 * is" without express or implied warranty.
 *
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 * OF THIS SOFTWARE.
 */

#include <linux/bug.h>
#include <linux/ctype.h>
#include <linux/export.h>
#include <linux/kernel.h>

#include <drm/drmP.h>
#include <drm/drm_fourcc.h>

static char printable_char(int c)
{
	return isascii(c) && isprint(c) ? c : '?';
}

/**
 * drm_mode_legacy_fb_format - compute drm fourcc code from legacy description
 * @bpp: bits per pixels
 * @depth: bit depth per pixel
 *
 * Computes a drm fourcc pixel format code for the given @bpp/@depth values.
 * Useful in fbdev emulation code, since that deals in those values.
 */
uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
{
	uint32_t fmt;

	switch (bpp) {
	case 8:
		fmt = DRM_FORMAT_C8;
		break;
	case 16:
		if (depth == 15)
			fmt = DRM_FORMAT_XRGB1555;
		else
			fmt = DRM_FORMAT_RGB565;
		break;
	case 24:
		fmt = DRM_FORMAT_RGB888;
		break;
	case 32:
		if (depth == 24)
			fmt = DRM_FORMAT_XRGB8888;
		else if (depth == 30)
			fmt = DRM_FORMAT_XRGB2101010;
		else
			fmt = DRM_FORMAT_ARGB8888;
		break;
	default:
		DRM_ERROR("bad bpp, assuming x8r8g8b8 pixel format\n");
		fmt = DRM_FORMAT_XRGB8888;
		break;
	}

	return fmt;
}
EXPORT_SYMBOL(drm_mode_legacy_fb_format);

/**
 * drm_get_format_name - fill a string with a drm fourcc format's name
 * @format: format to compute name of
 * @buf: caller-supplied buffer
 */
const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf)
{
	snprintf(buf->str, sizeof(buf->str),
		 "%c%c%c%c %s-endian (0x%08x)",
		 printable_char(format & 0xff),
		 printable_char((format >> 8) & 0xff),
		 printable_char((format >> 16) & 0xff),
		 printable_char((format >> 24) & 0x7f),
		 format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
		 format);

	return buf->str;
}
EXPORT_SYMBOL(drm_get_format_name);

/*
 * Internal function to query information for a given format. See
 * drm_format_info() for the public API.
 */
const struct drm_format_info *__drm_format_info(u32 format)
{
	static const struct drm_format_info formats[] = {
		{ .format = DRM_FORMAT_C8,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGB332,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGR233,		.depth = 8,  .num_planes = 1, .cpp = { 1, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XRGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XBGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRX4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_ARGB4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_ABGR4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRA4444,	.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XRGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XBGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRX5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_ARGB1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_ABGR1555,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRA5551,	.depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGB565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGR565,		.depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGB888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGR888,		.depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XRGB8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XBGR8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRX8888,	.depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGB565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGR565_A8,	.depth = 24, .num_planes = 2, .cpp = { 2, 1, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XRGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XBGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRX1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_ARGB2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_ABGR2101010,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRA1010102,	.depth = 30, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_ARGB8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_ABGR8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRA8888,	.depth = 32, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGB888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGR888_A8,	.depth = 32, .num_planes = 2, .cpp = { 3, 1, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XRGB8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_XBGR8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_RGBX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_BGRX8888_A8,	.depth = 32, .num_planes = 2, .cpp = { 4, 1, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_YUV410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4 },
		{ .format = DRM_FORMAT_YVU410,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 4 },
		{ .format = DRM_FORMAT_YUV411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1 },
		{ .format = DRM_FORMAT_YVU411,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 4, .vsub = 1 },
		{ .format = DRM_FORMAT_YUV420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2 },
		{ .format = DRM_FORMAT_YVU420,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 2 },
		{ .format = DRM_FORMAT_YUV422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1 },
		{ .format = DRM_FORMAT_YVU422,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 2, .vsub = 1 },
		{ .format = DRM_FORMAT_YUV444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_YVU444,		.depth = 0,  .num_planes = 3, .cpp = { 1, 1, 1 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_NV12,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2 },
		{ .format = DRM_FORMAT_NV21,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 2 },
		{ .format = DRM_FORMAT_NV16,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1 },
		{ .format = DRM_FORMAT_NV61,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 2, .vsub = 1 },
		{ .format = DRM_FORMAT_NV24,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_NV42,		.depth = 0,  .num_planes = 2, .cpp = { 1, 2, 0 }, .hsub = 1, .vsub = 1 },
		{ .format = DRM_FORMAT_YUYV,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
		{ .format = DRM_FORMAT_YVYU,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
		{ .format = DRM_FORMAT_UYVY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
		{ .format = DRM_FORMAT_VYUY,		.depth = 0,  .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 2, .vsub = 1 },
		{ .format = DRM_FORMAT_AYUV,		.depth = 0,  .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
	};

	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(formats); ++i) {
		if (formats[i].format == format)
			return &formats[i];
	}

	return NULL;
}

/**
 * drm_format_info - query information for a given format
 * @format: pixel format (DRM_FORMAT_*)
 *
 * The caller should only pass a supported pixel format to this function.
 * Unsupported pixel formats will generate a warning in the kernel log.
 *
 * Returns:
 * The instance of struct drm_format_info that describes the pixel format, or
 * NULL if the format is unsupported.
 */
const struct drm_format_info *drm_format_info(u32 format)
{
	const struct drm_format_info *info;

	info = __drm_format_info(format);
	WARN_ON(!info);
	return info;
}
EXPORT_SYMBOL(drm_format_info);

/**
 * drm_get_format_info - query information for a given framebuffer configuration
 * @dev: DRM device
 * @mode_cmd: metadata from the userspace fb creation request
 *
 * Returns:
 * The instance of struct drm_format_info that describes the pixel format, or
 * NULL if the format is unsupported.
 */
const struct drm_format_info *
drm_get_format_info(struct drm_device *dev,
		    const struct drm_mode_fb_cmd2 *mode_cmd)
{
	const struct drm_format_info *info = NULL;

	if (dev->mode_config.funcs->get_format_info)
		info = dev->mode_config.funcs->get_format_info(mode_cmd);

	if (!info)
		info = drm_format_info(mode_cmd->pixel_format);

	return info;
}
EXPORT_SYMBOL(drm_get_format_info);

/**
 * drm_format_num_planes - get the number of planes for format
 * @format: pixel format (DRM_FORMAT_*)
 *
 * Returns:
 * The number of planes used by the specified pixel format.
 */
int drm_format_num_planes(uint32_t format)
{
	const struct drm_format_info *info;

	info = drm_format_info(format);
	return info ? info->num_planes : 1;
}
EXPORT_SYMBOL(drm_format_num_planes);

/**
 * drm_format_plane_cpp - determine the bytes per pixel value
 * @format: pixel format (DRM_FORMAT_*)
 * @plane: plane index
 *
 * Returns:
 * The bytes per pixel value for the specified plane.
 */
int drm_format_plane_cpp(uint32_t format, int plane)
{
	const struct drm_format_info *info;

	info = drm_format_info(format);
	if (!info || plane >= info->num_planes)
		return 0;

	return info->cpp[plane];
}
EXPORT_SYMBOL(drm_format_plane_cpp);

/**
 * drm_format_horz_chroma_subsampling - get the horizontal chroma subsampling factor
 * @format: pixel format (DRM_FORMAT_*)
 *
 * Returns:
 * The horizontal chroma subsampling factor for the
 * specified pixel format.
 */
int drm_format_horz_chroma_subsampling(uint32_t format)
{
	const struct drm_format_info *info;

	info = drm_format_info(format);
	return info ? info->hsub : 1;
}
EXPORT_SYMBOL(drm_format_horz_chroma_subsampling);

/**
 * drm_format_vert_chroma_subsampling - get the vertical chroma subsampling factor
 * @format: pixel format (DRM_FORMAT_*)
 *
 * Returns:
 * The vertical chroma subsampling factor for the
 * specified pixel format.
 */
int drm_format_vert_chroma_subsampling(uint32_t format)
{
	const struct drm_format_info *info;

	info = drm_format_info(format);
	return info ? info->vsub : 1;
}
EXPORT_SYMBOL(drm_format_vert_chroma_subsampling);

/**
 * drm_format_plane_width - width of the plane given the first plane
 * @width: width of the first plane
 * @format: pixel format
 * @plane: plane index
 *
 * Returns:
 * The width of @plane, given that the width of the first plane is @width.
 */
int drm_format_plane_width(int width, uint32_t format, int plane)
{
	const struct drm_format_info *info;

	info = drm_format_info(format);
	if (!info || plane >= info->num_planes)
		return 0;

	if (plane == 0)
		return width;

	return width / info->hsub;
}
EXPORT_SYMBOL(drm_format_plane_width);

/**
 * drm_format_plane_height - height of the plane given the first plane
 * @height: height of the first plane
 * @format: pixel format
 * @plane: plane index
 *
 * Returns:
 * The height of @plane, given that the height of the first plane is @height.
 */
int drm_format_plane_height(int height, uint32_t format, int plane)
{
	const struct drm_format_info *info;

	info = drm_format_info(format);
	if (!info || plane >= info->num_planes)
		return 0;

	if (plane == 0)
		return height;

	return height / info->vsub;
}
EXPORT_SYMBOL(drm_format_plane_height);

{'repo_name': 'OnePlusOSS/android_kernel_oneplus_sm8150', 'stars': '115', 'repo_language': 'C', 'file_name': 'm5mols_controls.c', 'mime_type': 'text/x-c', 'hash': -3332798052045102123, 'source_dataset': 'data'}