Пример #1
0
static int clocksource_init (void)
{
	init_timebase();

	cs.mult = clocksource_hz2mult(get_timebase_clock(), cs.shift);

	init_clock(&cs);

	return 0;
}
Пример #2
0
int main()
{
	int choice = 0;
	int SelectSobelMode = SOBEL_OFF;
	pthread_t sw_sync_thread;
	int ret;
	int setResolution(void);

	if (setResolution() != 0)
	{
		// framebuffer with the required resolution not found.
		return -1;
	}

	// spawn a thread to check the sw synchronization while software sobel filter is On.
	ret = pthread_create( &sw_sync_thread, NULL, &thread_sw_sync, NULL);

	if (ret)
		{
		printf("ERROR; return code from pthread_create() is %d\n", ret);
		return -1;
		}

	//backup the current display layer so that we can restore it at the end.
	store_cvc_layer(LAYER_ID_0);

	// initial state
	clearMemory(gLayerBase[DISPLAY_LAYER], BUFFER_OFFSETS * 3);
	resetStop_VDMA_ALL();
	init_cvc(DISPLAY_LAYER, gResolution);
	init_timebase(gResolution);

#ifdef DEMO_MENU_MODE
	do
	{
		printf("\n-------------  Video Library Demo Main Menu:  --------------------\n\n");
		printf("1 -> Start TPG Pattern (Plain)\n");
		printf("2 -> TPG Pattern with Software (OpenCV) Filter\n");
		printf("3 -> TPG Pattern with Software Filter\n");
		printf("4 -> TPG Pattern with Hardware Filter\n");
		printf("5 -> Start Live Video (Plain)\n");
		printf("6 -> Live Video with Software (OpenCV) Filter\n");
		printf("7 -> Live Video with Software Filter\n");
		printf("8 -> Live Video with Hardware Filter\n");
		printf("0 -> Exit\n\n");

		printf("\nEnter your choice :");
		choice = getInput();

		switch(choice)
		{
		case 0:	// break;
			SelectSobelMode = SOBEL_OFF;
			ChangeSobelMode(SelectSobelMode);
			gActiveState = STATE_EXIT;
			printf("\n <== BYE BYE ==>\n");
			break;
		case 1: // Select TPG Pattern
			SelectSobelMode = SOBEL_OFF;
			gLiveVideoOn = 0;
			SetTpgPattern(gResolution, TPG_PATTERN_ID);
			ChangeSobelMode(SelectSobelMode);
			break;
		case 2:
			SelectSobelMode = SOBEL_SW;
			gLiveVideoOn = 0;
                        gSwUsingOpenCV = 1;
			SetTpgPattern(gResolution, TPG_PATTERN_ID);
			ChangeSobelMode(SelectSobelMode);
			break;
		case 3:
			SelectSobelMode = SOBEL_SW;
			gLiveVideoOn = 0;
                        gSwUsingOpenCV = 0;
			SetTpgPattern(gResolution, TPG_PATTERN_ID);
			ChangeSobelMode(SelectSobelMode);
			break;
		case 4:
			SelectSobelMode = SOBEL_HW;
			gLiveVideoOn = 0;
			SetTpgPattern(gResolution, TPG_PATTERN_ID);
			ChangeSobelMode(SelectSobelMode);
			break;
		case 5: // Live video
			SelectSobelMode = SOBEL_OFF;
			gLiveVideoOn = 1;
		//	SetTpgPattern(0x0);		This will be done while switching the input. (After confirming that we have right input)
			ChangeSobelMode(SelectSobelMode);
			break;
		case 6:
			SelectSobelMode = SOBEL_SW;
			gLiveVideoOn = 1;
                        gSwUsingOpenCV = 1;
		//	SetTpgPattern(0);		This will be done while switching the input.
			ChangeSobelMode(SelectSobelMode);
			break;
		case 7:
			SelectSobelMode = SOBEL_SW;
			gLiveVideoOn = 1;
                        gSwUsingOpenCV = 0;
		//	SetTpgPattern(0);		This will be done while switching the input.
			ChangeSobelMode(SelectSobelMode);
			break;
		case 8:
			SelectSobelMode = SOBEL_HW;
			gLiveVideoOn = 1;
		//	SetTpgPattern(0);		This will be done while switching the input.
			ChangeSobelMode(SelectSobelMode);
			break;

		default:
			printf("\n\n ********* Invalid input, Please try Again ***********\n");
			break;
		}
		if (choice <=8 && choice > 0)
			printf("\n\n <== Input Mode : %s / Filter Mode : %s ==>\n",(gLiveVideoOn)?"Live Video":"TPG Pattern",
				(choice == 1 || choice == 5)?"OFF":((choice == 4 || choice == 8)?"HW":"SW"));
	}while(choice);
#else
	do
	{
		printf("\n-------------  Linux Sobel Filter Demo Main Menu:  --------------------\n\n");
		printf("1 -> Select TPG Pattern\n");
		printf("2 -> Sobel Filter On / Off \n");
		printf("0 -> Exit");
		printf("\nEnter your choice :");
		choice = getInput();

		switch(choice)
		{
		case 0:	// break;
			SelectSobelMode = SOBEL_OFF;
			ChangeSobelMode(SelectSobelMode);
			// should use mutext to protect the shared resource.
			gActiveState = STATE_EXIT;
			break;
		case 1: // Select TPG Pattern
			SelectTPG(SelectSobelMode);
			break;
		case 2: // Turn Sobel Filter On / off

			printf("Select Sobel options\n\n");

			printf("%d: Disable Sobel Filter \n",SOBEL_OFF);
			printf("%d: Enable Hardware Sobel Filter \n",SOBEL_HW);
			printf("%d: Enable Software Sobel Filter \n",SOBEL_SW);

			printf("\nEnter your choice :");
			//scanf(" %d", &SelectSobelMode);	printf("--UIO--newMode = %d\n", newMode);
			SelectSobelMode = getInput();

			switch(SelectSobelMode)
			{
			case SOBEL_HW:
				printf("\nTurning ON Hardware Sobel Filter ..\n");
				break;
			case SOBEL_SW:
				printf("\nTurning ON Software Sobel Filter..\n");
				break;
			default:
				SelectSobelMode = SOBEL_OFF;
				printf("\nTurning OFF Sobel Filter..\n");
				break;
			}
			ChangeSobelMode(SelectSobelMode);
			break;
		default:
			printf("\n\n ********* Invalid input, Please try Again ***********\n");
			break;
		}

	}while(choice);
#endif
	pthread_join(sw_sync_thread,NULL);

	restore_cvc_layer(LAYER_ID_0);

	return 0;
}